Documentation ¶
Overview ¶
Package zapr defines an implementation of the github.com/go-logr/logr interfaces built on top of Zap (go.uber.org/zap).
Usage ¶
A new logr.Logger can be constructed from an existing zap.Logger using the NewLogger function:
log := zapr.NewLogger(someZapLogger)
Implementation Details ¶
For the most part, concepts in Zap correspond directly with those in logr.
Unlike Zap, all fields *must* be in the form of sugared fields -- it's illegal to pass a strongly-typed Zap field in a key position to any of the log methods.
Levels in logr correspond to custom debug levels in Zap. Any given level in logr is represents by its inverse in zap (`zapLevel = -1*logrLevel`). For example V(2) is equivalent to log level -2 in Zap, while V(1) is equivalent to Zap's DebugLevel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*zapLogger)
Option is one additional parameter for NewLoggerWithOptions.
func AllowZapFields ¶
AllowZapFields controls whether strongly-typed Zap fields may be passed instead of a key/value pair. This is disabled by default because it breaks implementation agnosticism.
func DPanicOnBugs ¶
DPanicOnBugs controls whether extra log messages are emitted for invalid log calls with zap's DPanic method. Depending on the configuration of the zap logger, the program then panics after emitting the log message which is useful in development because such invalid log calls are bugs in the program. The log messages explain why a call was invalid (for example, non-string key). Emitting them is enabled by default.
func ErrorKey ¶
ErrorKey replaces the default "error" field name used for the error in Logger.Error calls.
func LogInfoLevel ¶
LogInfoLevel controls whether a numeric log level is added to Info log message. The empty string disables this, a non-empty string is the key for the additional field. Errors and internal panic messages do not have a log level and thus are always logged without this extra field.
func VerbosityLevel ¶
VerbosityLevel sets the verbosity level of the logger. It is used to determine whether a log message is actually logged. The default is 0 which means that no debug log messages are logged. A higher value means that more log messages are logged.