Documentation
¶
Overview ¶
Package zerologr defines an implementation of the github.com/go-logr/logr interfaces built on top of Zerolog (https://github.com/rs/zerolog).
Usage ¶
A new logr.Logger can be constructed from an existing zerolog.Logger using the New function:
log := zerologr.New(someZeroLogger)
Implementation Details ¶
For the most part, concepts in Zerolog correspond directly with those in logr.
Levels in logr correspond to custom debug levels in Zerolog. Any given level in logr is represents by `zerologLevel = 1 - logrLevel`. For example V(2) is equivalent to Zerolog's TraceLevel, while V(1) is equivalent to Zerolog's DebugLevel. Zerolog's usual "level" field is disabled globally and replaced with "v", whose value is a number and is only logged on Info(), not Error().
Index ¶
- Variables
- type LogSink
- func (ls *LogSink) Enabled(level int) bool
- func (ls *LogSink) Error(err error, msg string, keysAndValues ...interface{})
- func (ls *LogSink) GetUnderlying() *zerolog.Logger
- func (ls *LogSink) Info(level int, msg string, keysAndValues ...interface{})
- func (ls *LogSink) Init(ri logr.RuntimeInfo)
- func (ls LogSink) WithCallDepth(depth int) logr.LogSink
- func (ls LogSink) WithName(name string) logr.LogSink
- func (ls LogSink) WithValues(keysAndValues ...interface{}) logr.LogSink
- type Logger
- type Underlier
Constants ¶
This section is empty.
Variables ¶
var ( // NameFieldName is the field key for logr.WithName NameFieldName = "logger" // NameSeparator separates names for logr.WithName NameSeparator = "/" )
Functions ¶
This section is empty.
Types ¶
type LogSink ¶
type LogSink struct {
// contains filtered or unexported fields
}
LogSink implements logr.LogSink and logr.CallDepthLogSink.
func NewLogSink ¶
NewLogSink returns a logr.LogSink implemented by Zerolog.
func (*LogSink) GetUnderlying ¶ added in v1.1.0
GetUnderlying returns the zerolog.Logger underneath this logSink.
func (*LogSink) Info ¶
Info logs a non-error message at specified V-level with the given key/value pairs as context.
func (*LogSink) Init ¶
func (ls *LogSink) Init(ri logr.RuntimeInfo)
Init receives runtime info about the logr library.
func (LogSink) WithCallDepth ¶
WithCallDepth returns a new LogSink that offsets the call stack by adding specified depths.
func (LogSink) WithName ¶
WithName returns a new LogSink with the specified name appended in NameFieldName. Name elements are separated by NameSeparator.
func (LogSink) WithValues ¶
WithValues returns a new LogSink with additional key/value pairs.