Documentation ¶
Overview ¶
Package distillog provides a minimalistic logging interface (inspired by the stdlib) that also supports levelled logging.
You can instantiate a logger (that adheres to the Logger interface) or use the pkg level log functions (like the stdlib).
You can set where the log messages are sent to by either either instantiating your own logger using the appropriate constructor function, or by using SetOutput to configure the pkg level logger.
You may also use `lumberjack` or a similar library in conjunction with this one to manage (rotate) your log files.
Visit the README at https://github.com/amoghe/distillog
Index ¶
- func Close()
- func Debugf(format string, v ...interface{})
- func Debugln(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infoln(v ...interface{})
- func SetOutput(out io.WriteCloser)
- func Warningf(format string, v ...interface{})
- func Warningln(v ...interface{})
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf logs a message to stderr at 'debug' level
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf logs a message to stderr at 'error' level
func Infof ¶
func Infof(format string, v ...interface{})
Infof logs a message to stderr at 'info' level
func SetOutput ¶
func SetOutput(out io.WriteCloser)
SetOutput allows you to configure the package level logger to emit to the specified output stream. NOTE: this is not safe when called concurrently from multiple goroutines. This should typically be called once during program initialization before spawning goroutines that may use the log.
Types ¶
type Logger ¶
type Logger interface { Debugf(format string, v ...interface{}) Debugln(v ...interface{}) Infof(format string, v ...interface{}) Infoln(v ...interface{}) Warningf(format string, v ...interface{}) Warningln(v ...interface{}) Errorf(format string, v ...interface{}) Errorln(v ...interface{}) Close() error }
Logger defines a distilled interface for logging messages from your program. Note: All functions append a trailing newline if one doesn't exist.
func NewNullLogger ¶
NewNullLogger returns a logger that drops messages (outputs to /dev/null).
func NewStderrLogger ¶
NewStderrLogger returns a Logger that outputs messages to Stderr.
func NewStdoutLogger ¶
NewStdoutLogger returns a Logger that outputs messages to Stdout.
func NewStreamLogger ¶
func NewStreamLogger(tag string, stream io.WriteCloser) Logger
NewStreamLogger returns a Logger that outputs messages to the specified stream.
func NewSyslogLogger ¶
NewSyslogLogger returns a Logger that sends messages to the Syslog daemon. This will panic if it is unable to connect to the local syslog daemon.