diff --git a/client/driver/logging/syslog_parser_unix.go b/client/driver/logging/syslog_parser_unix.go index e39ac7cf7..4e0fec555 100644 --- a/client/driver/logging/syslog_parser_unix.go +++ b/client/driver/logging/syslog_parser_unix.go @@ -92,13 +92,14 @@ func (d *DockerLogParser) logContentIndex(line []byte) int { } } } - // then the colon is what seperates it + // then the colon is what seperates it, followed by a space for i := cursor; i < len(line); i++ { - if line[i] == ':' { - cursor = i + if line[i] == ':' && i+1 < len(line) && line[i+1] == ' ' { + cursor = i + 1 break } } + // return the cursor to the next character return cursor + 1 } diff --git a/client/driver/logging/syslog_parser_unix_test.go b/client/driver/logging/syslog_parser_unix_test.go index 80adc0007..5aa3345ec 100644 --- a/client/driver/logging/syslog_parser_unix_test.go +++ b/client/driver/logging/syslog_parser_unix_test.go @@ -3,6 +3,7 @@ package logging import ( + "bytes" "log" "log/syslog" "os" @@ -21,7 +22,7 @@ func TestLogParser_Priority(t *testing.T) { } idx := d.logContentIndex(line) - expected := 68 + expected := bytes.Index(line, []byte("1:C 10 Feb 18:16:43.391")) if idx != expected { t.Fatalf("expected idx: %v, got: %v", expected, idx) } @@ -39,7 +40,7 @@ func TestLogParser_Priority_UnixFormatter(t *testing.T) { } idx := d.logContentIndex(line) - expected := 48 + expected := bytes.Index(line, []byte("1:C 10 Feb 18:16:43.391")) if idx != expected { t.Fatalf("expected idx: %v, got: %v", expected, idx) }