(line: string)
| 47 | } |
| 48 | |
| 49 | private logLine(line: string): void { |
| 50 | if (!line.trim()) { |
| 51 | this.inTraceback = false; |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | if (this.inTraceback && /^\s/.test(line)) { |
| 56 | this.writeLog('error', line); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | const trimmedStart = line.trimStart(); |
| 61 | if (/^Traceback \(most recent call last\):/i.test(trimmedStart)) { |
| 62 | this.inTraceback = true; |
| 63 | this.writeLog('error', line); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | const prefixMatch = /^(DEBUG|INFO|WARN|WARNING|ERROR|CRITICAL|FATAL)\b[: ]?/i.exec( |
| 68 | trimmedStart, |
| 69 | ); |
| 70 | if (prefixMatch) { |
| 71 | this.inTraceback = false; |
| 72 | this.writeLog(this.normalizeLevel(prefixMatch[1]), line); |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | if (this.inTraceback) { |
| 77 | this.inTraceback = false; |
| 78 | this.writeLog('error', line); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if ( |
| 83 | /^(During handling of the above exception|The above exception was the direct cause)/i.test( |
| 84 | trimmedStart, |
| 85 | ) |
| 86 | ) { |
| 87 | this.writeLog('error', line); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | this.writeLog('warn', line); |
| 92 | } |
| 93 | |
| 94 | private normalizeLevel(level: string): StderrLevel { |
| 95 | switch (level.toUpperCase()) { |
no test coverage detected