mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 23:21:41 +01:00
fix: improves logfmt (#2729)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -156,6 +157,8 @@ func readEvent(reader *bufio.Reader, tty bool) (string, StdType, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var validLogFmtKey = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
|
||||
|
||||
func createEvent(message string, streamType StdType) *LogEvent {
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(message))
|
||||
@@ -190,13 +193,13 @@ func createEvent(message string, streamType StdType) *LogEvent {
|
||||
for decoder.ScanKeyval() {
|
||||
key := decoder.Key()
|
||||
value := decoder.Value()
|
||||
if len(value) == 0 {
|
||||
if validLogFmtKey.Match(key) == false {
|
||||
allValid = false
|
||||
break
|
||||
}
|
||||
data[string(key)] = string(value)
|
||||
}
|
||||
if allValid && len(data) > 0 {
|
||||
if allValid && len(data) > 1 {
|
||||
logEvent.Message = data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user