Documentation ¶
Overview ¶
Package syslogger uses the event package to listen for any event that implements the Syslogger interface. The listener calls the Syslog method on the event, which should return a severity and a message.
The tag for messages sent to syslog will be the program name (os.Args[0]), and the facility number will be 1 (user-level).
For example, to declare that your event type MyEvent should be sent to syslog, implement the Syslog() method to define how the message should be formatted and which severity it should have (see package "log/syslog" for details).
import ( "fmt" "log/syslog" "syslogger" ) type MyEvent struct { field1, field2 string } func (ev *MyEvent) Syslog() (syslog.Priority, string) { return syslog.LOG_INFO, fmt.Sprintf("event: %v, %v", ev.field1, ev.field2) } var _ syslogger.Syslogger = (*MyEvent)(nil) // compile-time interface check
The compile-time interface check is optional but recommended because usually there is no other static conversion in these cases. See:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestLogger ¶ added in v0.15.4
func NewTestLogger() *testLogger