예제 #1
0
func ExampleNewParser() {
	b := `<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] An application event log entry...`
	buff := []byte(b)

	p := rfc5424.NewParser(buff)
	err := p.Parse()
	if err != nil {
		panic(err)
	}

	fmt.Println(p.Dump())
}
예제 #2
0
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)
	}
}
예제 #3
0
func (f *RFC6587) GetParser(line []byte) syslogparser.LogParser {
	return rfc5424.NewParser(line)
}
예제 #4
0
func (f *RFC6587) GetParser(line []byte) LogParser {
	return &parserWrapper{rfc5424.NewParser(line)}
}