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