mcuadros / go-syslog

Syslog server library for go.
http://godoc.org/gopkg.in/mcuadros/go-syslog.v2
MIT License
523 stars 143 forks source link

Failing to parse syslog sent from Go stdlib #45

Closed ianic closed 6 years ago

ianic commented 6 years ago

I took the example from stdlib to send a message to go-syslog.

Line is incorrectly parsed:

hostname:
priority:28
facility:3
severity:4
client:127.0.0.1:65519
timestamp:2018-01-12 16:10:14 +0100 CET
content:2018-01-12T16:10:14+01:00 Callisto.local demotag[40516]: This is a daemon warning with demotag.

should be:

timestamp:2018-01-12 16:11:36 +0100 +0100
hostname:Callisto.local
content:This is a daemon warning with demotag.
priority:28
facility:3
tag:demotag
severity:4
client:127.0.0.1:61861

The problem is that stdlib is sending timestamp in time.RFC339 and go-syslog is expecting time in time.Stamp format.

It seams that go-syslog is following rfc, but it is strange that Go lib is not parsing syslog generated by standard library.

From rfc:

The TIMESTAMP field is the local time and is in the format of "Mmm dd hh:mm:ss" (without the quote marks)