(message: string, data?: unknown)
| 37 | * Only writes when enabled via setDebugLogEnabled(true). |
| 38 | */ |
| 39 | export function debugLog(message: string, data?: unknown): void { |
| 40 | if (!debugLogEnabled) { |
| 41 | return |
| 42 | } |
| 43 | try { |
| 44 | const logDir = path.dirname(DEBUG_LOG_PATH) |
| 45 | |
| 46 | if (!fs.existsSync(logDir)) { |
| 47 | fs.mkdirSync(logDir, { recursive: true }) |
| 48 | } |
| 49 | |
| 50 | const timestamp = new Date().toISOString() |
| 51 | |
| 52 | const entry = data |
| 53 | ? `[${timestamp}] ${message}: ${JSON.stringify(data, null, 2)}\n` |
| 54 | : `[${timestamp}] ${message}\n` |
| 55 | |
| 56 | fs.appendFileSync(DEBUG_LOG_PATH, entry) |
| 57 | } catch { |
| 58 | // NO-OP - don't let logging errors break functionality |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Debug logger with component context. |
no outgoing calls
no test coverage detected