Back to godoc.org
github.com/influxdata/go-syslog

package syslog

v1.0.2 (8318965)
Latest Go to latest
Published: Aug 14, 2019 | License: MIT | Module: github.com/influxdata/go-syslog

Overview

Package syslog provides generic interfaces and structs for syslog messages and transport. Subpackages contains various parsers or scanners for different syslog formats.

Index

type BestEfforter

type BestEfforter interface {
	WithBestEffort()
	HasBestEffort() bool
}

BestEfforter is an interface that wraps the HasBestEffort method.

type Machine

type Machine interface {
	Parse(input []byte) (Message, error)
	BestEfforter
}

Machine represent a FSM able to parse an entire syslog message and return it in an structured way.

type MachineOption

type MachineOption func(m Machine) Machine

MachineOption represents the type of option setters for Machine instances.

type Message

type Message interface {
	Valid() bool
	Priority() *uint8
	Version() uint16
	Facility() *uint8
	Severity() *uint8
	FacilityMessage() *string
	FacilityLevel() *string
	SeverityMessage() *string
	SeverityLevel() *string
	SeverityShortLevel() *string
	Timestamp() *time.Time
	Hostname() *string
	ProcID() *string
	Appname() *string
	MsgID() *string
	Message() *string
	StructuredData() *map[string]map[string]string
}

Message represent a structured representation of a syslog message.

type Parser

type Parser interface {
	Parse(r io.Reader)
	WithListener(ParserListener)
	BestEfforter
}

Parser is an interface that wraps the Parse method.

type ParserListener

type ParserListener func(*Result)

ParserListener is a function that receives syslog parsing results, one by one.

type ParserOption

type ParserOption func(p Parser) Parser

ParserOption represent the type of option setters for Parser instances.

func WithBestEffort

func WithBestEffort() ParserOption

WithBestEffort returns a generic options that enables best effort mode for syslog parsers.

When passed to a parser it tries to recover as much of the syslog messages as possible.

func WithListener

func WithListener(f ParserListener) ParserOption

WithListener returns a generic option that sets the emit function for syslog parsers.

type Result

type Result struct {
	Message Message
	Error   error
}

Result wraps the outcomes obtained parsing a syslog message.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier