Skip to content

Commit f80f7bd

Browse files
authored
Fix newline parsing (#81)
1 parent 2b0f7b0 commit f80f7bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cmd/gonzo/extractors.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ func extractLogEntryFromOTLPRecord(record *logspb.LogRecord) *tui.LogEntry {
121121

122122
// createFallbackLogEntry creates a basic LogEntry for unparseable lines
123123
func createFallbackLogEntry(line string) *tui.LogEntry {
124-
// Replace tabs with spaces to prevent formatting issues
124+
// Replace tabs and newlines with spaces to prevent formatting issues
125125
cleanLine := strings.ReplaceAll(line, "\t", " ")
126+
cleanLine = strings.ReplaceAll(cleanLine, "\n", " ")
127+
cleanLine = strings.ReplaceAll(cleanLine, "\r", " ")
126128

127129
// Extract severity from the message text instead of defaulting to INFO
128130
severity := extractSeverityFromText(cleanLine)
@@ -213,8 +215,11 @@ func extractMessageFromBody(body *commonpb.AnyValue) string {
213215

214216
switch v := body.Value.(type) {
215217
case *commonpb.AnyValue_StringValue:
216-
// Replace tabs with spaces to prevent formatting issues
217-
return strings.ReplaceAll(v.StringValue, "\t", " ")
218+
// Replace tabs and newlines with spaces to prevent formatting issues
219+
msg := strings.ReplaceAll(v.StringValue, "\t", " ")
220+
msg = strings.ReplaceAll(msg, "\n", " ")
221+
msg = strings.ReplaceAll(msg, "\r", " ")
222+
return msg
218223
case *commonpb.AnyValue_IntValue:
219224
return fmt.Sprintf("%d", v.IntValue)
220225
case *commonpb.AnyValue_DoubleValue:

0 commit comments

Comments
 (0)