docs: 基本完成初版数据库设计

This commit is contained in:
R524809
2026-10-15 10:09:34 +08:00
parent 63a6993276
commit e6ded00a4c
41 changed files with 2597 additions and 180 deletions
+28
View File
@@ -0,0 +1,28 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { AppLogger } from '../src/logging/app-logger';
test('日志为单行 JSON,递归脱敏并安全处理循环对象与 bigint', () => {
const output: string[] = [];
const logger = new AppLogger('info', (line) => output.push(line));
const nested: Record<string, unknown> = {
password: 'private-password',
amount: 9n,
};
nested.self = nested;
logger.log('test_event', {
authorization: 'Bearer private-token',
nested,
body: { code: 'login-secret' },
});
logger.debug('hidden');
assert.equal(output.length, 1);
const log = JSON.parse(output[0]!);
assert.equal(log.context.authorization, '[REDACTED]');
assert.equal(log.context.nested.password, '[REDACTED]');
assert.equal(log.context.nested.self, '[Circular]');
assert.equal(log.context.nested.amount, '9');
assert.equal(log.context.body, '[REDACTED]');
assert.ok(!output[0]!.includes('private-'));
assert.ok(!output[0]!.includes('login-secret'));
});