(line: string)
| 72 | } |
| 73 | |
| 74 | function write(line: string): void { |
| 75 | if (++writesSinceCheck >= ROTATE_CHECK_INTERVAL) { |
| 76 | writesSinceCheck = 0 |
| 77 | rotateIfNeeded() |
| 78 | } |
| 79 | // TUIs like OpenCode capture or overdraw stderr, so debug output is invisible |
| 80 | // in the user's terminal. Write to a file the user can tail from a second terminal. |
| 81 | // Also emit to stderr in case someone is running a non-TUI client. |
| 82 | try { |
| 83 | process.stderr.write(line) |
| 84 | } catch {} |
| 85 | try { |
| 86 | ensureLogDir() |
| 87 | appendFileSync(logFile, line) |
| 88 | } catch {} |
| 89 | } |
| 90 | |
| 91 | export function debug(scope: string, ...parts: unknown[]): void { |
| 92 | if (!enabled) return |
no test coverage detected