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 ¶
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 (*Server) AddUDPListener ¶
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 ¶
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 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
Click to show internal directories.
Click to hide internal directories.