remove the expected leading space, after the colon in syslog

This commit is contained in:
Cameron Davison 2016-07-06 11:02:00 -05:00
parent 07a9e15560
commit 921a6c889c
2 changed files with 7 additions and 5 deletions

View file

@ -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
}

View file

@ -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)
}