diff --git a/cmd/circologd/main.go b/cmd/circologd/main.go index f0a2de2..435f412 100644 --- a/cmd/circologd/main.go +++ b/cmd/circologd/main.go @@ -22,6 +22,20 @@ func cleanSocket(socket string) { } } +func setSyslogFormat(server *syslog.Server, format string) { + switch { + case format == "auto": + server.SetFormat(syslog.Automatic) + case format == "rfc3164": + server.SetFormat(syslog.RFC3164) + case format == "rfc5424": + server.SetFormat(syslog.RFC5424) + } + // TODO: propose a patch to mcuadros/go-syslog.v2 + // to get the format from the server itself. + log.Printf("Syslog format set to: %s\n", format) +} + func main() { var err error syslogSocketPath := flag.String("syslogd-socket", "", "The socket to listen to syslog addresses") @@ -31,6 +45,7 @@ func main() { queryAddr := flag.String("query-addr", "127.0.0.1:9080", "Address:port where to bind the query service") querySocket := flag.String("query-socket", "", "Path to a unix domain socket for the HTTP server; recommended for security reasons!") ctlSocket := flag.String("ctl-socket", "/tmp/circologd-ctl.sock", "Path to a unix domain socket for the control server; leave empty to disable") + logFmt := flag.String("log-fmt", "auto", "Log messages format. If not set, defaults to automatic choice. Allowed values: rfc3164, rfc5424.") verbose := flag.Bool("verbose", false, "Print more output executing the daemon") debug := flag.Bool("debug", false, "Print debugging info executing the daemon") flag.Parse() @@ -43,7 +58,7 @@ func main() { go hub.Run() server := syslog.NewServer() - server.SetFormat(syslog.Automatic) + setSyslogFormat(server, *logFmt) server.SetHandler(handler) if *syslogSocketPath != "" { if err = server.ListenUnixgram(*syslogSocketPath); err != nil {