go-syslog: github.com/influxdata/go-syslog Index | Files | Directories

package syslog

import "github.com/influxdata/go-syslog"

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


Package Files

options.go syslog.go

type Base Uses

type Base struct {
    Facility  *uint8
    Severity  *uint8
    Priority  *uint8
    Timestamp *time.Time
    Hostname  *string
    Appname   *string
    ProcID    *string
    MsgID     *string
    Message   *string

Base represents a base struct for syslog messages.

It contains the fields in common among different formats.

func (*Base) ComputeFromPriority Uses

func (m *Base) ComputeFromPriority(value uint8)

ComputeFromPriority set the priority values and computes facility and severity from it.

It does NOT check the input value validity.

func (*Base) FacilityLevel Uses

func (m *Base) FacilityLevel() *string

FacilityLevel returns the

func (*Base) FacilityMessage Uses

func (m *Base) FacilityMessage() *string

FacilityMessage returns the text message for the current facility value.

func (*Base) SeverityLevel Uses

func (m *Base) SeverityLevel() *string

SeverityLevel returns the text level for the current severity value.

func (*Base) SeverityMessage Uses

func (m *Base) SeverityMessage() *string

SeverityMessage returns the text message for the current severity value.

func (*Base) SeverityShortLevel Uses

func (m *Base) SeverityShortLevel() *string

SeverityShortLevel returns the short text level for the current severity value.

func (*Base) Valid Uses

func (m *Base) Valid() bool

Valid tells whether the receiving message is well-formed or not.

A minimally well-formed RFC3164 syslog message contains at least the priority ([1, 191] or 0). A minimally well-formed RFC5424 syslog message also contains the version.

type BestEfforter Uses

type BestEfforter interface {
    HasBestEffort() bool

BestEfforter is an interface that wraps the HasBestEffort method.

type Machine Uses

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

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

type MachineOption Uses

type MachineOption func(m Machine) Machine

MachineOption represents the type of option setters for Machine instances.

type MaxMessager Uses

type MaxMessager interface {
    WithMaxMessageLength(length int)

MaxMessager sets the max message size the parser should be able to parse

type Message Uses

type Message interface {
    Valid() bool
    FacilityMessage() *string
    FacilityLevel() *string
    SeverityMessage() *string
    SeverityLevel() *string
    SeverityShortLevel() *string

    ComputeFromPriority(value uint8)

Message represent a minimal syslog message.

type Parser Uses

type Parser interface {
    Parse(r io.Reader)

Parser is an interface that wraps the Parse method.

type ParserListener Uses

type ParserListener func(*Result)

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

type ParserOption Uses

type ParserOption func(p Parser) Parser

ParserOption represent the type of option setters for Parser instances.

func WithBestEffort Uses

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 Uses

func WithListener(f ParserListener) ParserOption

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

func WithMaxMessageLength Uses

func WithMaxMessageLength(length int) ParserOption

WithMaxMessageLength sets the length of the buffer for octect parsing.

type Result Uses

type Result struct {
    Message Message
    Error   error

Result wraps the outcomes obtained parsing a syslog message.



Package syslog imports 3 packages (graph) and is imported by 3 packages. Updated 2020-12-01. Refresh now. Tools for package owners.