rfc3164

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: 5 Imported by: 34

Documentation

Index

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

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

func (p *Parser) Hostname(hostname string)

DEPRECATED. Use WithHostname() instead

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)

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) WithTag

func (p *Parser) WithTag(t string)

Forces a tag. Tag will not be parsed

func (*Parser) WithTimestampFormat

func (p *Parser) WithTimestampFormat(s string)

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

Jump to

Keyboard shortcuts

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