Documentation ¶
Overview ¶
Package log allows consumers of the lxkns module to forward logging originating in the lxkns module to whatever logger module they prefer.
The accompanying package github.com/thediveo/lxkns/log/logrus can be used as a simple means to forward all lxkns-originating logging messages to the standard sirupsen/logrus logger instance. YMMV, however.
To forward lxkns-originating log messages to a different logging module only needs an adaptor implementing the Logger interface: it consists of just two methods:
- Log(level Level, msg string)
- SetLevel(level Level)
A consumer of the lxkns module then sets her specific logging adapter:
SetLog(myadapter)
An adapter can either forward the SetLevel method, but it is also perfectly fine to ignore these interface calls: this allows keeping separate logging levels for lxkns and the consuming application; for instance, disabling or restricting lxkns logging while still doing verbose application logging.
Index ¶
- func Debugf(format string, args ...interface{})
- func Debugfn(fn func() string)
- func Errorf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func Infofn(fn func() string)
- func LevelEnabled(level Level) bool
- func SetLevel(level Level)
- func SetLogger(logger Logger)
- func Tracef(format string, args ...interface{})
- func Tracefn(fn func() string)
- func Warnf(format string, args ...interface{})
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs formatted debug information.
func Debugfn ¶
func Debugfn(fn func() string)
Debugfn logs debugging information from the specified fn producer function.
func Infofn ¶
func Infofn(fn func() string)
Infofn logs information from the specified fn producer function.
func LevelEnabled ¶ added in v0.26.4
LevelEnabled takes a logging level and returns true, if this level is enabled. Compared with the *fn logging functions LevelEnabled avoids creating closures and allows optimizing hot paths further at the expense of slightly more elaborate logging calling sites.
func SetLevel ¶
func SetLevel(level Level)
SetLevel sets the logging level for lxkns-internal module logging. Depending on the external logger adapter, the level setting might also be propagated to this external logger.
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger sets the logging adapter to be used. Please note that this is not a multiple Go-routine safe operation, so it should be carried out before spawning any logging Go routines.
func Tracef ¶
func Tracef(format string, args ...interface{})
Tracef logs formatted trace information.