Documentation ¶
Index ¶
- Constants
- Variables
- type Parser
- func (p *Parser) Dump() syslogparser.LogParts
- func (p *Parser) Location(location *time.Location)
- func (p *Parser) Parse() error
- func (p *Parser) WithHostname(h string)
- func (p *Parser) WithLocation(l *time.Location)
- func (p *Parser) WithPriority(pri *parsercommon.Priority)
- func (p *Parser) WithTag(t string)
- func (p *Parser) WithTimestampFormat(s string)
Examples ¶
Constants ¶
View Source
const ( NILVALUE = '-' // according to https://tools.ietf.org/html/rfc5424#section-6.1 // the length of the packet MUST be 2048 bytes or less. // However we will accept a bit more while protecting from exhaustion MAX_PACKET_LEN = 3048 )
Variables ¶
View Source
var ( ErrYearInvalid = &parsercommon.ParserError{ErrorString: "Invalid year in timestamp"} ErrMonthInvalid = &parsercommon.ParserError{ErrorString: "Invalid month in timestamp"} ErrDayInvalid = &parsercommon.ParserError{ErrorString: "Invalid day in timestamp"} ErrHourInvalid = &parsercommon.ParserError{ErrorString: "Invalid hour in timestamp"} ErrMinuteInvalid = &parsercommon.ParserError{ErrorString: "Invalid minute in timestamp"} ErrSecondInvalid = &parsercommon.ParserError{ErrorString: "Invalid second in timestamp"} ErrSecFracInvalid = &parsercommon.ParserError{ErrorString: "Invalid fraction of second in timestamp"} ErrTimeZoneInvalid = &parsercommon.ParserError{ErrorString: "Invalid time zone in timestamp"} ErrInvalidTimeFormat = &parsercommon.ParserError{ErrorString: "Invalid time format"} ErrInvalidAppName = &parsercommon.ParserError{ErrorString: "Invalid app name"} ErrInvalidProcId = &parsercommon.ParserError{ErrorString: "Invalid proc ID"} ErrInvalidMsgId = &parsercommon.ParserError{ErrorString: "Invalid msg ID"} ErrNoStructuredData = &parsercommon.ParserError{ErrorString: "No structured data"} )
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
Example ¶
package main import ( "fmt" "github.com/jeromer/syslogparser/rfc5424" ) func main() { 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) } for k, v := range p.Dump() { fmt.Println(k, ":", v) } }
Output:
func (*Parser) Dump ¶
func (p *Parser) Dump() syslogparser.LogParts
func (*Parser) WithHostname ¶
Forces a hostname. Hostname will not be parsed
func (*Parser) WithLocation ¶
Noop as RFC5424 syslog always has a timezone
func (*Parser) WithPriority ¶
func (p *Parser) WithPriority(pri *parsercommon.Priority)
Forces a priority for this parser. Priority will not be parsed.
func (*Parser) WithTag ¶
Noop as RFC5424 as no tag per se: The TAG has been split into APP-NAME, PROCID, and MSGID. Ref: https://tools.ietf.org/html/rfc5424#appendix-A.1
func (*Parser) WithTimestampFormat ¶
Noop as RFC5424 is strict about timestamp format
Click to show internal directories.
Click to hide internal directories.