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() {
|
||||
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 {
|
||||
|
|
|
@ -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 ""
|
||||
|
|
Loading…
Reference in a new issue