| 22 | } |
| 23 | |
| 24 | function normalizeMessage(message: unknown): string { |
| 25 | let text: string; |
| 26 | if (typeof message === "string") { |
| 27 | text = message; |
| 28 | } else if (message instanceof Error) { |
| 29 | text = message.message; |
| 30 | } else { |
| 31 | try { |
| 32 | text = JSON.stringify(message); |
| 33 | } catch { |
| 34 | text = String(message); |
| 35 | } |
| 36 | } |
| 37 | return stripAnsi(String(text || "")) |
| 38 | .replace(/\[LSP:[^\]]+\]\s*/g, "") |
| 39 | .replace(/\[LSP-STDERR:[^\]]+\]\s*/g, "") |
| 40 | .replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\s*/g, "") |
| 41 | .replace(/\s*(INFO|WARN|ERROR|DEBUG|TRACE)\s+/gi, "") |
| 42 | .replace(/[a-z_]+::[a-z_]+:\s*/gi, "") |
| 43 | .trim(); |
| 44 | } |
| 45 | |
| 46 | function shouldIgnoreLog(message: string): boolean { |
| 47 | return IGNORED_LOG_PATTERNS.some((pattern) => pattern.test(message)); |