@@ -8,3 +8,57 @@ func (s *FormatSuite) TestRFC3164_SingleSplit(c *C) {
8
8
f := RFC3164 {}
9
9
c .Assert (f .GetSplitFunc (), IsNil )
10
10
}
11
+
12
+ func (s * FormatSuite ) TestRFC3164_CorrectParsingTypical (c * C ) {
13
+ f := RFC3164 {}
14
+
15
+ find := `<13>May 1 20:51:40 myhostname myprogram: ciao`
16
+ parser := f .GetParser ([]byte (find ))
17
+ err := parser .Parse ()
18
+ c .Assert (err , IsNil )
19
+ c .Assert (parser .Dump ()["content" ], Equals , "ciao" )
20
+ c .Assert (parser .Dump ()["hostname" ], Equals , "myhostname" )
21
+ c .Assert (parser .Dump ()["tag" ], Equals , "myprogram" )
22
+
23
+ }
24
+ func (s * FormatSuite ) TestRFC3164_CorrectParsingTypicalWithPID (c * C ) {
25
+ f := RFC3164 {}
26
+
27
+ find := `<13>May 1 20:51:40 myhostname myprogram[42]: ciao`
28
+ parser := f .GetParser ([]byte (find ))
29
+ err := parser .Parse ()
30
+ c .Assert (err , IsNil )
31
+ c .Assert (parser .Dump ()["content" ], Equals , "ciao" )
32
+ c .Assert (parser .Dump ()["hostname" ], Equals , "myhostname" )
33
+ c .Assert (parser .Dump ()["tag" ], Equals , "myprogram" )
34
+
35
+ }
36
+
37
+ func (s * FormatSuite ) TestRFC3164_CorrectParsingGNU (c * C ) {
38
+ // GNU implementation of syslog() has a variant: hostname is missing
39
+ f := RFC3164 {}
40
+
41
+ find := `<13>May 1 20:51:40 myprogram: ciao`
42
+ parser := f .GetParser ([]byte (find ))
43
+ err := parser .Parse ()
44
+ c .Assert (err , IsNil )
45
+ c .Assert (parser .Dump ()["content" ], Equals , "ciao" )
46
+ // c.Assert(parser.Dump()["hostname"], Equals, "myhostname")
47
+ c .Assert (parser .Dump ()["tag" ], Equals , "myprogram" )
48
+
49
+ }
50
+
51
+ func (s * FormatSuite ) TestRFC3164_CorrectParsingJournald (c * C ) {
52
+ // GNU implementation of syslog() has a variant: hostname is missing
53
+ // systemd uses it, and typically also passes PID
54
+ f := RFC3164 {}
55
+
56
+ find := `<78>May 1 20:51:02 myprog[153]: blah`
57
+ parser := f .GetParser ([]byte (find ))
58
+ err := parser .Parse ()
59
+ c .Assert (err , IsNil )
60
+ c .Assert (parser .Dump ()["content" ], Equals , "blah" )
61
+ // c.Assert(parser.Dump()["hostname"], Equals, "myhostname")
62
+ c .Assert (parser .Dump ()["tag" ], Equals , "myprog" )
63
+
64
+ }
0 commit comments