Documentation ¶
Index ¶
- Constants
- type Parser
- func (p *Parser) Dump() syslogparser.LogParts
- func (p *Parser) Hostname(hostname string)
- 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 ( // according to https://tools.ietf.org/html/rfc3164#section-4.1 // "The total length of the packet MUST be 1024 bytes or less" // However we will accept a bit more while protecting from exhaustion MAX_PACKET_LEN = 2048 )
Variables ¶
This section is empty.
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/rfc3164" ) func main() { 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) } 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 ¶
Forces a location. UTC will be used otherwise.
func (*Parser) WithPriority ¶
func (p *Parser) WithPriority(pri *parsercommon.Priority)
Forces a priority for this parser. Priority will not be parsed.
func (*Parser) WithTimestampFormat ¶
Forces a given time format. Refer to pkg/time layouts for more informations By default the following formats will be tried in order: Jan 02 15:04:05 Jan 2 15:04:05 The timezone MUST be specified using WithLocation() and not using WithTimestampFormat
Click to show internal directories.
Click to hide internal directories.