Compare commits
3 commits
55827916bb
...
f73c25d099
Author | SHA1 | Date | |
---|---|---|---|
f73c25d099 | |||
0e6b078ad6 | |||
76a6381516 |
2 changed files with 9 additions and 8 deletions
|
@ -26,7 +26,7 @@ func cleanSocket(socket string) {
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
var logFmt formatter.SyslogRFC
|
var logFmt formatter.SyslogRFC
|
||||||
logFmt.Format = syslog.Automatic
|
logFmt.Fmt = syslog.Automatic
|
||||||
syslogSocketPath := flag.String("syslogd-socket", "", "The socket to listen to syslog addresses")
|
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")
|
// 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")
|
bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep")
|
||||||
|
@ -47,8 +47,7 @@ func main() {
|
||||||
go hub.Run()
|
go hub.Run()
|
||||||
|
|
||||||
server := syslog.NewServer()
|
server := syslog.NewServer()
|
||||||
server.SetFormat(logFmt.Format)
|
server.SetFormat(logFmt.Fmt)
|
||||||
fmt.Printf("Syslog format set to: %s\n", logFmt.String())
|
|
||||||
server.SetHandler(handler)
|
server.SetHandler(handler)
|
||||||
if *syslogSocketPath != "" {
|
if *syslogSocketPath != "" {
|
||||||
if err = server.ListenUnixgram(*syslogSocketPath); err != nil {
|
if err = server.ListenUnixgram(*syslogSocketPath); err != nil {
|
||||||
|
|
|
@ -8,24 +8,26 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SyslogRFC is the formatter that the server should use
|
// 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 {
|
func (rfc *SyslogRFC) Set(v string) error {
|
||||||
newval, err := parseRFCValue(v)
|
newval, err := parseRFCValue(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rfc.Format = newval
|
rfc.Fmt = newval
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rfc *SyslogRFC) String() string {
|
func (rfc *SyslogRFC) String() string {
|
||||||
switch {
|
switch {
|
||||||
case rfc.Format == syslog.Automatic:
|
case rfc.Fmt == syslog.Automatic:
|
||||||
return "auto"
|
return "auto"
|
||||||
case rfc.Format == syslog.RFC3164:
|
case rfc.Fmt == syslog.RFC3164:
|
||||||
return "rfc3164"
|
return "rfc3164"
|
||||||
case rfc.Format == syslog.RFC5424:
|
case rfc.Fmt == syslog.RFC5424:
|
||||||
return "rfc5424"
|
return "rfc5424"
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
Loading…
Reference in a new issue