Compare commits

..

3 commits

2 changed files with 9 additions and 8 deletions

View file

@ -26,7 +26,7 @@ func cleanSocket(socket string) {
func main() {
var err error
var logFmt formatter.SyslogRFC
logFmt.Format = syslog.Automatic
logFmt.Fmt = syslog.Automatic
syslogSocketPath := flag.String("syslogd-socket", "", "The socket to listen to syslog addresses")
// dumpSocketPath := flag.String("dump-socket", "/run/buffer.sock", "The socket that user will connect to in order to receive logs")
bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep")
@ -47,8 +47,7 @@ func main() {
go hub.Run()
server := syslog.NewServer()
server.SetFormat(logFmt.Format)
fmt.Printf("Syslog format set to: %s\n", logFmt.String())
server.SetFormat(logFmt.Fmt)
server.SetHandler(handler)
if *syslogSocketPath != "" {
if err = server.ListenUnixgram(*syslogSocketPath); err != nil {

View file

@ -8,24 +8,26 @@ import (
)
// SyslogRFC is the formatter that the server should use
type SyslogRFC struct{ format.Format }
type SyslogRFC struct {
Fmt format.Format
}
func (rfc *SyslogRFC) Set(v string) error {
newval, err := parseRFCValue(v)
if err != nil {
return err
}
rfc.Format = newval
rfc.Fmt = newval
return nil
}
func (rfc *SyslogRFC) String() string {
switch {
case rfc.Format == syslog.Automatic:
case rfc.Fmt == syslog.Automatic:
return "auto"
case rfc.Format == syslog.RFC3164:
case rfc.Fmt == syslog.RFC3164:
return "rfc3164"
case rfc.Format == syslog.RFC5424:
case rfc.Fmt == syslog.RFC5424:
return "rfc5424"
}
return ""