Documentation
¶
Overview ¶
Pacakge rfc5424 is a library for parsing and serializing RFC-5424 structured syslog messages.
Example usage:
m := rfc5424.Message{
Priority: rfc5424.Daemon | rfc5424.Info,
Timestamp: time.Now(),
Hostname: "myhostname",
AppName: "someapp",
Message: []byte("Hello, World!"),
}
m.AddDatum("foo@1234", "Revision", "1.2.3.4")
m.WriteTo(os.Stdout)
Produces output like:
107 <7>1 2016-02-28T09:57:10.804642398-05:00 myhostname someapp - - [foo@1234 Revision="1.2.3.4"] Hello, World!
You can also use the library to parse syslog messages:
m := rfc5424.Message{}
_, err := m.ReadFrom(os.Stdin)
fmt.Printf("%s\n", m.Message)
Index ¶
Constants ¶
const RFC5424TimeOffsetNum = "2006-01-02T15:04:05.999999-07:00"
RFC5424TimeOffsetNum is the timestamp defined by RFC-5424 with the NUMOFFSET instead of Z.
const RFC5424TimeOffsetUTC = "2006-01-02T15:04:05.999999Z"
RFC5424TimeOffsetUTC is the timestamp defined by RFC-5424 with the offset set to 0 for UTC.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrBadFormat ¶
type ErrBadFormat struct {
Property string
}
ErrBadFormat is the error that is returned when a log message cannot be parsed
func (ErrBadFormat) Error ¶
func (e ErrBadFormat) Error() string
type ErrInvalidValue ¶
type ErrInvalidValue struct {
Property string
Value interface{}
}
ErrInvalidValue is returned when a log message cannot be emitted because one of the values is invalid.
func (ErrInvalidValue) Error ¶
func (e ErrInvalidValue) Error() string
type Message ¶
type Message struct {
Priority Priority
Timestamp time.Time
UseUTC bool
Hostname string
AppName string
ProcessID string
MessageID string
StructuredData []StructuredData
Message []byte
}
Message represents a log message as defined by RFC-5424 (https://tools.ietf.org/html/rfc5424)
func (Message) MarshalBinary ¶
MarshalBinary marshals the message to a byte slice, or returns an error
func (*Message) UnmarshalBinary ¶
UnmarshalBinary unmarshals a byte slice into a message
type StructuredData ¶
StructuredData represents structured data within a log message

