fix: escaping of : and \ in keyvalue formatter
This commit is contained in:
parent
a98708a4a9
commit
6b40c8ccf6
2 changed files with 2 additions and 2 deletions
|
@ -65,7 +65,7 @@ func (formatter *FormatterKeyValue) addKV(key string, value any) {
|
|||
val := fmt.Sprintf("%v", value)
|
||||
|
||||
// check, if value should be escaped
|
||||
if strings.ContainsAny(val, " \t\n\r=") {
|
||||
if strings.ContainsAny(val, " \t\n\r=:\\") {
|
||||
val = fmt.Sprintf("%q", val)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestFormatterKeyValue(t *testing.T) {
|
|||
},
|
||||
Level: LevelInfo,
|
||||
}
|
||||
result := `time=0001-01-01T00:00:00Z level=INFO message="Some Text" k1=v1 k2=v2`
|
||||
result := `time="0001-01-01T00:00:00Z" level=INFO message="Some Text" k1=v1 k2=v2`
|
||||
|
||||
// execute formatter
|
||||
formatter := NewFormatterKeyValue()
|
||||
|
|
Loading…
Add table
Reference in a new issue