(level: string, msg: string)
| 14 | let logFilePath: string | null = null; |
| 15 | |
| 16 | function writeToFile(level: string, msg: string) { |
| 17 | if (!logFilePath) return; |
| 18 | const line = JSON.stringify({ |
| 19 | timestamp: new Date().toISOString(), |
| 20 | level, |
| 21 | message: msg, |
| 22 | }) + "\n"; |
| 23 | appendFileSync(logFilePath, line, "utf8"); |
| 24 | } |
| 25 | |
| 26 | export function initFileLog() { |
| 27 | if (logFilePath) return; |