(
message: string,
{ level }: { level: DebugLogLevel } = {
level: 'debug',
},
)
| 373 | } |
| 374 | |
| 375 | export function logForDebugging( |
| 376 | message: string, |
| 377 | { level }: { level: DebugLogLevel } = { |
| 378 | level: 'debug', |
| 379 | }, |
| 380 | ): void { |
| 381 | if (LEVEL_ORDER[level] < LEVEL_ORDER[getMinDebugLogLevel()]) { |
| 382 | return |
| 383 | } |
| 384 | if (!shouldLogDebugMessage(message)) { |
| 385 | return |
| 386 | } |
| 387 | |
| 388 | // Multiline messages break the jsonl output format, so make any multiline messages JSON. |
| 389 | if (hasFormattedOutput && message.includes('\n')) { |
| 390 | message = jsonStringify(message) |
| 391 | } |
| 392 | const timestamp = new Date().toISOString() |
| 393 | const output = `${timestamp} [${level.toUpperCase()}] ${message.trim()}\n` |
| 394 | if (isDebugToStdErr()) { |
| 395 | writeToStderr(output) |
| 396 | return |
| 397 | } |
| 398 | |
| 399 | getDebugWriter().write(output) |
| 400 | } |
| 401 | |
| 402 | export function getDebugLogPath(): string { |
| 403 | return ( |
no test coverage detected