44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
/*
|
|
Package logging implements and presents various loggers under a unified interface, making them completely swappable.
|
|
|
|
These particular loggers (logging.Logger) available are:
|
|
|
|
StdLogger
|
|
FileLogger
|
|
SystemDLogger (Linux only)
|
|
SyslogLogger (Linux only)
|
|
WinLogger (Windows only)
|
|
|
|
There is a sixth type of logging.Logger, MultiLogger, that allows for multiple loggers to be written to with a single call.
|
|
|
|
Every logging.Logger type has the following methods that correspond to certain "levels".
|
|
|
|
Alert(s string, v ...interface{}) (err error)
|
|
Crit(s string, v ...interface{}) (err error)
|
|
Debug(s string, v ...interface{}) (err error)
|
|
Emerg(s string, v ...interface{}) (err error)
|
|
Err(s string, v ...interface{}) (err error)
|
|
Info(s string, v ...interface{}) (err error)
|
|
Notice(s string, v ...interface{}) (err error)
|
|
Warning(s string, v ...interface{}) (err error)
|
|
|
|
Not all loggers implement the concept of levels, so approximations are made when/where possible.
|
|
|
|
In each of the above methods, s is the message that is optionally in a fmt.Sprintf-compatible format.
|
|
If it is, the values to fmt.Sprintf can be passed as v.
|
|
|
|
Note that in the case of a MultiLogger, err (if not nil) will be a (r00t2.io/goutils/)multierr.MultiError.
|
|
|
|
logging.Logger types also have the following methods:
|
|
|
|
DoDebug(d bool)
|
|
SetPrefix(p string)
|
|
GetPrefix() (p string)
|
|
Setup()
|
|
Shutdown()
|
|
|
|
In some cases, Logger.Setup and Logger.Shutdown are no-ops. In other cases, they perform necessary initialization/cleanup and closing of the logger.
|
|
It is recommended to *always* run Setup and Shutdown before and after using, respectively, regardless of the actual logging.Logger type.
|
|
*/
|
|
package logging
|