func (f *Automatic) GetParser(line []byte) syslogparser.LogParser { switch format, _ := detect(line); format { case detectedRFC3164: return rfc3164.NewParser(line) case detectedRFC5424: return rfc5424.NewParser(line) default: // If the line was an RFC6587 line, the splitter should already have removed the length, // so one of the above two will be chosen if the line is correctly formed. However, it // may have a second length illegally placed at the start, in which case the detector // will return detectedRFC6587. The line may also simply be malformed after the length in // which case we will have detectedUnknown. In this case we return the simplest parser so // the illegally formatted line is properly handled return rfc3164.NewParser(line) } }
func ExampleNewParser() { b := "<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8" buff := []byte(b) p := rfc3164.NewParser(buff) err := p.Parse() if err != nil { panic(err) } fmt.Println(p.Dump()) }
func (f *RFC3164) GetParser(line []byte) syslogparser.LogParser { return rfc3164.NewParser(line) }
func (f *RFC3164) GetParser(line []byte) LogParser { return &parserWrapper{rfc3164.NewParser(line)} }