2022-01-05 05:15:38 -05:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
|
2022-01-05 16:16:24 -05:00
|
|
|
Note that for some Loggers, the prefix may be modified - "literal" loggers (StdLogger and FileLogger) will append a space to the end of the prefix.
|
|
|
|
If this is undesired (unlikely), you will need to modify (Logger).Prefix and run (Logger).Logger.SetPrefix(yourPrefixHere) for the respective logger.
|
|
|
|
|
|
|
|
|
2022-01-05 05:15:38 -05:00
|
|
|
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
|