feat(logging): Wave 1 - logging infrastructure complete

- Add logging config to config.yaml with level, auditRetention, appRetention
- Add 4 global exception handlers (uncaughtException, unhandledRejection, render-process-gone, child-process-gone)
- Create audit-logger.ts with JSONL format and 30-day rotation
- Define IPC logger channels (LOGGER_FORWARD) and preload API
- Define audit types (AuditAction enum, AuditEntry interface, AuditStatus enum)
- Add unit tests for audit logger

All typechecks passing. Wave 1 complete.
This commit is contained in:
test
2026-03-08 13:49:31 +08:00
parent f45d3df385
commit 5e6898fb40
9 changed files with 450 additions and 18 deletions

View File

@@ -52,9 +52,9 @@ const createFileTransport = (level?: string): DailyRotateFile => {
})
}
// Create the logger instance
// Create the logger instance with default level
const logger = winston.createLogger({
level: 'info', // Log level is now hardcoded, can be moved to config.yaml if needed
level: 'info', // Default level, can be updated via setLogLevel()
defaultMeta: { service: 'erpauto' },
transports: [
// Console transport - always enabled
@@ -66,6 +66,14 @@ const logger = winston.createLogger({
]
})
/**
* Update the logger level dynamically
* @param level - The new log level
*/
export function setLogLevel(level: string): void {
logger.level = level
}
// Add error-specific file transport in production
if (app.isPackaged) {
logger.add(