Skip to content

Commit 0a0cd4d

Browse files
authored
fix: escape newlines in panic stack trace for better log collection (#44)
1 parent 1c84f01 commit 0a0cd4d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/wrapper/plugin_wrapper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,9 @@ func recoverFunc() {
12591259
const size = 64 << 10
12601260
buf := make([]byte, size)
12611261
buf = buf[:runtime.Stack(buf, false)]
1262-
log.Errorf("recovered from panic %v, stack: %s", r, buf)
1262+
// Escape newlines to ensure the entire stack trace is printed on a single line,
1263+
// which prevents log collection systems from splitting the stack trace into multiple entries
1264+
escapedStack := strings.ReplaceAll(string(buf), "\n", "\\n")
1265+
log.Errorf("recovered from panic %v, stack: %s", r, escapedStack)
12631266
}
12641267
}

0 commit comments

Comments
 (0)