syslog

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FRAME_MODE_DELIMITER = iota
	FRAME_MODE_OCTET_COUNTED

	FORMAT_RFC3164 = iota
)

Variables

View Source
var (
	RFC3164 = regexp.MustCompile(`<([0-9]+)>([A-Z][a-z][a-z]\s{1,2}\d{1,2}\s\d{2}[:]\d{2}[:]\d{2})\s([\w][\w\d\.@-]*)\s([^: []+)(?:\[([0-9]+)\])?[: [] ?((.|\n)*)`)

	InvalidMessageError   = errors.New("Invalid Message")
	InvalidPriortyError   = errors.New("Invalid Priority")
	InvalidPIDError       = errors.New("Invalid PID")
	InvalidTimestampError = errors.New("Invalid Timestamp")
)
View Source
var (
	OctetRe = regexp.MustCompile(`^(\d+)`)

	InvalidOctetErr = errors.New("Invalid Octet Prefix")
)

Functions

func ParseRFC3164Inplace

func ParseRFC3164Inplace(msg *SyslogMessage, data string) error

A parser which dumps results into an existing SyslogMessage struct. This can

be used for better performance and to avoid allocations

Types

type InvalidMessage

type InvalidMessage struct {
	Data  string
	Error error
}

Struct which contains an invalid Syslog message that failed to parse. This

can be used to introspect and monitor errors.

type ParserInplaceFunc

type ParserInplaceFunc func(msg *SyslogMessage, data string) error

type Server

type Server struct {
	Messages chan SyslogData
	Errors   chan InvalidMessage
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *ServerConfig, messages chan SyslogData, errors chan InvalidMessage) *Server

func (*Server) AddTCPListener

func (s *Server) AddTCPListener(li net.Listener)

func (*Server) AddUDPListener

func (s *Server) AddUDPListener(li net.Conn)

type ServerConfig

type ServerConfig struct {
	// The TCP framing mode to operate in (only valid for TCP)
	TCPFrameMode int

	// The syslog format to use
	Format int
}

Used to configure the Syslog Server

type SyslogBuffer

type SyslogBuffer struct {
	Buffer   []byte
	Size     int
	LastSize int
}

func NewSyslogBuffer

func NewSyslogBuffer() *SyslogBuffer

func (*SyslogBuffer) Append

func (sb *SyslogBuffer) Append(data []byte)

func (*SyslogBuffer) Next

func (sb *SyslogBuffer) Next() []byte

func (*SyslogBuffer) NextLine

func (sb *SyslogBuffer) NextLine() []byte

type SyslogData

type SyslogData map[string]interface{}

A wrapper type for structured SyslogData

type SyslogMessage

type SyslogMessage struct {
	Priority  int
	Timestamp time.Time
	Hostname  string
	Tag       string
	PID       int
	Content   string
}

func ParseRFC3164

func ParseRFC3164(data string) (*SyslogMessage, error)

func (*SyslogMessage) ToMapping

func (sm *SyslogMessage) ToMapping() map[string]interface{}

Returns a mapping

Jump to

Keyboard shortcuts

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