remove the expected leading space, after the colon in syslog
This commit is contained in:
parent
07a9e15560
commit
921a6c889c
|
@ -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++ {
|
for i := cursor; i < len(line); i++ {
|
||||||
if line[i] == ':' {
|
if line[i] == ':' && i+1 < len(line) && line[i+1] == ' ' {
|
||||||
cursor = i
|
cursor = i + 1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// return the cursor to the next character
|
||||||
return cursor + 1
|
return cursor + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"log"
|
"log"
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"os"
|
"os"
|
||||||
|
@ -21,7 +22,7 @@ func TestLogParser_Priority(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
idx := d.logContentIndex(line)
|
idx := d.logContentIndex(line)
|
||||||
expected := 68
|
expected := bytes.Index(line, []byte("1:C 10 Feb 18:16:43.391"))
|
||||||
if idx != expected {
|
if idx != expected {
|
||||||
t.Fatalf("expected idx: %v, got: %v", expected, idx)
|
t.Fatalf("expected idx: %v, got: %v", expected, idx)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +40,7 @@ func TestLogParser_Priority_UnixFormatter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
idx := d.logContentIndex(line)
|
idx := d.logContentIndex(line)
|
||||||
expected := 48
|
expected := bytes.Index(line, []byte("1:C 10 Feb 18:16:43.391"))
|
||||||
if idx != expected {
|
if idx != expected {
|
||||||
t.Fatalf("expected idx: %v, got: %v", expected, idx)
|
t.Fatalf("expected idx: %v, got: %v", expected, idx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue