Skip to content
Syslog server library for go.
Branch: master
Clone or download
ianic and mcuadros Add support for timestamp in RFC3339 format (#47)
Default Go log/syslog is sending syslog messages in that format:
https://github.com/golang/go/blob/9745eed4fd4160cfbf55e9dbbfa99aca5563b392/src/log/syslog/syslog.go#L294

That is not according to the standard:
"The TIMESTAMP field is the local time and is in the format of "Mmm dd hh:mm:ss" (without the quote marks)"
(https://tools.ietf.org/html/rfc3164#section-5.3)

But it is necessery if we want to parse lines sent by log/syslog.

One small fix, time.Stamp is same as those two formats:
-               "Jan 02 15:04:05",
-               "Jan  2 15:04:05",
+               time.Stamp,
Latest commit a127d82 Jan 16, 2018

README.md

go-syslog Build Status GoDoc GitHub release

Syslog server library for go, build easy your custom syslog server over UDP, TCP or Unix sockets using RFC3164, RFC6587 or RFC5424

Installation

The recommended way to install go-syslog

go get gopkg.in/mcuadros/go-syslog.v2

Examples

How import the package

import "gopkg.in/mcuadros/go-syslog.v2"

Example of a basic syslog UDP server:

channel := make(syslog.LogPartsChannel)
handler := syslog.NewChannelHandler(channel)

server := syslog.NewServer()
server.SetFormat(syslog.RFC5424)
server.SetHandler(handler)
server.ListenUDP("0.0.0.0:514")
server.Boot()

go func(channel syslog.LogPartsChannel) {
    for logParts := range channel {
        fmt.Println(logParts)
    }
}(channel)

server.Wait()

License

MIT, see LICENSE

You can’t perform that action at this time.