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