()
| 29 | } |
| 30 | |
| 31 | function flush(): void { |
| 32 | if (flushTimer) { |
| 33 | clearTimeout(flushTimer); |
| 34 | flushTimer = null; |
| 35 | } |
| 36 | if (buffer.length === 0) return; |
| 37 | const data = buffer.join(""); |
| 38 | buffer = []; |
| 39 | try { |
| 40 | const logFile = getMagicContextLogPath(); |
| 41 | ensureDir(logFile); |
| 42 | fs.appendFileSync(logFile, data); |
| 43 | } catch { |
| 44 | // Intentional: logging must never throw |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | function scheduleFlush(): void { |
| 49 | if (flushTimer) return; |
no test coverage detected