rfc5424

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2021 License: BSD-2-Clause Imports: 7 Imported by: 30

Documentation

Index

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

func NewParser(buff []byte) *Parser
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) Location

func (p *Parser) Location(location *time.Location)

DEPRECATED. Use WithLocation() instead

func (*Parser) Parse

func (p *Parser) Parse() error

func (*Parser) WithHostname

func (p *Parser) WithHostname(h string)

Forces a hostname. Hostname will not be parsed

func (*Parser) WithLocation

func (p *Parser) WithLocation(l *time.Location)

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

func (p *Parser) WithTag(t string)

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

func (p *Parser) WithTimestampFormat(s string)

Noop as RFC5424 is strict about timestamp format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL