fix(logger): address code review findings

- Remove misleading await from audit-logger tests (functions are sync)
- Add cleanup() to LoggerAPI type definition in index.d.ts
- Fix circular reference fallback to preserve null values

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-03 21:37:59 +08:00
parent 6a9d144bbc
commit 6413eef5b8
3 changed files with 21 additions and 17 deletions

View File

@@ -61,10 +61,13 @@ const consoleFormat = winston.format.combine(
try {
metaStr = ` ${JSON.stringify(meta, null, 2)}`
} catch {
// Fallback for circular references: stringify primitives, replace objects with placeholder
// Fallback for circular references: stringify primitives, replace complex objects with placeholder
metaStr = ` ${JSON.stringify(
Object.fromEntries(
Object.entries(meta).map(([k, v]) => [k, typeof v === 'object' ? '[Object]' : v])
Object.entries(meta).map(([k, v]) => [
k,
v !== null && typeof v === 'object' ? `[Object]` : v
])
),
null,
2

View File

@@ -130,6 +130,7 @@ export interface ConfigAPI {
export interface LoggerAPI {
log: (level: LogLevel, message: string, context?: Record<string, unknown>) => void
fetchLevel: () => Promise<void>
cleanup: () => void
}
export interface UpdateAPI {