Documentation ¶
Overview ¶
Notifier - Go logging package (syslog, file and e-mail)
Index ¶
- type Msg
- type MsgType
- type Notifier
- func (n *Notifier) AddLoggerCallback(s Severity, f func(*Msg)) error
- func (n *Notifier) AddLoggerEmailSMTP(s Severity, server, user, pass, from, to, subject string, ...) error
- func (n *Notifier) AddLoggerFile(s Severity, file string) error
- func (n *Notifier) AddLoggerStdout(s Severity) error
- func (n *Notifier) AddLoggerSyslog(s Severity, address string, facility SyslogFacility) error
- func (n *Notifier) Attach(s Severity, t string) error
- func (n *Notifier) Close() chan bool
- func (n *Notifier) Flush()
- func (n *Notifier) Print(s Severity, v ...interface{})
- func (n *Notifier) Printf(s Severity, format string, v ...interface{})
- func (n *Notifier) Reopen()
- func (n *Notifier) Send(s Severity, t string) error
- type Severity
- type SyslogFacility
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Msg ¶
A single message.
func (*Msg) String ¶
String implements the fmt.Stringer interface. It returns the message as a single string in human readable format.
func (*Msg) SyslogString ¶
func (m *Msg) SyslogString(facility SyslogFacility, tag string) string
SyslogString returns the message in a format suitable for sending to BSD style syslogd.
func (*Msg) TimeString ¶
TimeString is like String() but omits the date from the output.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier is a logging subsystem instance which is running as a goroutine and may have several different logging destinations.
func (*Notifier) AddLoggerCallback ¶
AddLoggerCallback adds a log output which just calls back the given function whenever there is a message to be logged.
func (*Notifier) AddLoggerEmailSMTP ¶
func (n *Notifier) AddLoggerEmailSMTP(s Severity, server, user, pass, from, to, subject string, throttle time.Duration) error
AddLoggerEmailSMTP adds an e-mail logging output. The e-mails are sent with ESMTP/SMTP whenever Flush() is called.
func (*Notifier) AddLoggerFile ¶
AddLoggerFile adds a file based logging output.
func (*Notifier) AddLoggerStdout ¶
AddLoggerStdout adds a logger which outputs to the standard output. This can be useful for running a program in debugging mode.
func (*Notifier) AddLoggerSyslog ¶
func (n *Notifier) AddLoggerSyslog(s Severity, address string, facility SyslogFacility) error
AddLoggerSyslog adds a Unix syslog logging output.
func (*Notifier) Attach ¶
Attach sends an attachment for logging. Attachments are usually some additional multi-line output which provide further insight into a problem. Examples: stack trace in case of panic, parser input in case of a parse error. Some logging destinations such as syslog do not support logging attachments. For others attachments can be enabled or disabled when setting up the logging destination.
func (*Notifier) Close ¶
Close log outputs. Causes the outputs to be flushed and stops the goroutines gracefully. Returns a channel which is closed when the logging subsystem has shut down. The caller may choose to wait until it is closed in case something takes a long time (such as sendind an e-mail message).
func (*Notifier) Flush ¶
func (n *Notifier) Flush()
Flush all buffered logging output. This should be called when the program finishes "one round". Causes for example e-mails to be sent instead of waiting for more log lines.
type Severity ¶
type Severity uint32
Message severity levels, matches with syslog severity levels.