(
message: string,
{ level }: { level: DebugLogLevel } = {
level: 'debug',
},
)
| 199 | } |
| 200 | |
| 201 | export function logForDebugging( |
| 202 | message: string, |
| 203 | { level }: { level: DebugLogLevel } = { |
| 204 | level: 'debug', |
| 205 | }, |
| 206 | ): void { |
| 207 | if (LEVEL_ORDER[level] < LEVEL_ORDER[getMinDebugLogLevel()]) { |
| 208 | return |
| 209 | } |
| 210 | if (!shouldLogDebugMessage(message)) { |
| 211 | return |
| 212 | } |
| 213 | |
| 214 | // Multiline messages break the jsonl output format, so make any multiline messages JSON. |
| 215 | if (hasFormattedOutput && message.includes('\n')) { |
| 216 | message = jsonStringify(message) |
| 217 | } |
| 218 | const timestamp = new Date().toISOString() |
| 219 | const output = `${timestamp} [${level.toUpperCase()}] ${message.trim()}\n` |
| 220 | if (isDebugToStdErr()) { |
| 221 | writeToStderr(output) |
| 222 | return |
| 223 | } |
| 224 | |
| 225 | getDebugWriter().write(output) |
| 226 | } |
| 227 | |
| 228 | export function getDebugLogPath(): string { |
| 229 | return ( |
no test coverage detected