MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeMessage

Function normalizeMessage

src/cm/lsp/logs.ts:24–44  ·  view source on GitHub ↗
(message: unknown)

Source from the content-addressed store, hash-verified

22}
23
24function 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
46function shouldIgnoreLog(message: string): boolean {
47 return IGNORED_LOG_PATTERNS.some((pattern) => pattern.test(message));

Callers 1

addLspLogFunction · 0.85

Calls 2

StringInterface · 0.85
stripAnsiFunction · 0.85

Tested by

no test coverage detected