Skip to content

Commit

Permalink
fix: fixes parsing of logfmt logs with a regex. fixes #2834
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Mar 19, 2024
1 parent cb99bcd commit 9230902
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/docker/event_generator.go
Expand Up @@ -156,7 +156,8 @@ func readEvent(reader *bufio.Reader, tty bool) (string, StdType, error) {
}
}

var validLogFmtKey = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
var validLogFmtMessage = regexp.MustCompile(`([a-zA-Z0-9_.-]+)=(?:(?:"(.*)")|(?:(?:([^\s]+)[\s])))`)
var validLogFmtKey = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)

func createEvent(message string, streamType StdType) *LogEvent {
h := fnv.New32a()
Expand All @@ -180,7 +181,7 @@ func createEvent(message string, streamType StdType) *LogEvent {
} else {
logEvent.Message = data
}
} else if strings.Contains(message, "=") {
} else if validLogFmtMessage.MatchString(message) {
buffer := bufPool.Get().(*bytes.Buffer)
buffer.Reset()
defer bufPool.Put(buffer)
Expand Down

0 comments on commit 9230902

Please sign in to comment.