(level: LogLevel, msg: string, meta?: Record<string, unknown>)
| 54 | } |
| 55 | |
| 56 | private async write(level: LogLevel, msg: string, meta?: Record<string, unknown>): Promise<void> { |
| 57 | if (LEVEL_PRIORITY[level] < LEVEL_PRIORITY[this.minLevel]) return; |
| 58 | const ts = new Date().toISOString(); |
| 59 | const metaStr = meta ? ' ' + JSON.stringify(meta) : ''; |
| 60 | const line = `${ts} [${level.toUpperCase()}] ${msg}${metaStr}`; |
| 61 | |
| 62 | if (!this.initialized) { |
| 63 | this.buffer.push(line); |
| 64 | return; |
| 65 | } |
| 66 | try { |
| 67 | await fs.appendFile(this.logFile, line + '\n'); |
| 68 | } catch { /* intentional: logger must never throw */ } |
| 69 | } |
| 70 | |
| 71 | debug(msg: string, meta?: Record<string, unknown>): void { void this.write('debug', msg, meta); } |
| 72 | info(msg: string, meta?: Record<string, unknown>): void { void this.write('info', msg, meta); } |
no test coverage detected