Documentation ¶
Overview ¶
Package genericr implements github.com/go-logr/logr.LogSink in a generic way that allows easy implementation of other logging backends.
Index ¶
- func NewForTesting(t TLogSink) logr.Logger
- type Entry
- type LogFunc
- type LogSink
- func (l LogSink) Enabled(level int) bool
- func (l LogSink) Error(err error, msg string, kvList ...interface{})
- func (l LogSink) Info(level int, msg string, kvList ...interface{})
- func (l LogSink) Init(info logr.RuntimeInfo)
- func (l LogSink) WithCallDepth(depth int) logr.LogSink
- func (l LogSink) WithCaller(enabled bool) LogSink
- func (l LogSink) WithName(name string) logr.LogSink
- func (l LogSink) WithValues(kvList ...interface{}) logr.LogSink
- func (l LogSink) WithVerbosity(level int) LogSink
- type TLogSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewForTesting ¶
NewForTesting returns a LogSink for given testing.T or B. Note that the source line reference will be incorrect in all messages written by testing.T. There is nothing we can do about that, the call depth is hardcoded in there.
Types ¶
type Entry ¶
type Entry struct { Level int // level at which this was logged Name string // name parts joined with '.' NameParts []string // individual name segments Message string // message as send to log call Error error // error if .Error() was called Fields []interface{} // alternating key-value pairs // Caller information Caller runtime.Frame // only available after .WithCaller(true) CallerDepth int // caller depth from callback }
Entry is a log entry that your adapter will receive for actual logging
func (Entry) CallerShort ¶ added in v0.2.0
CallerShort returns a short caller location string ("somefile.go:123")
type LogSink ¶ added in v0.3.0
type LogSink struct {
// contains filtered or unexported fields
}
LogSink is a generic logger that implements the logr.LogSink interface and calls a function of type LogFunc for every log message received.
func (LogSink) Init ¶ added in v0.3.0
func (l LogSink) Init(info logr.RuntimeInfo)
func (LogSink) WithCallDepth ¶ added in v0.3.1
WithCallDepth implements logr.CallDepthLogSink.
func (LogSink) WithCaller ¶ added in v0.3.0
WithCaller enables or disables caller lookup for Entry.Caller. It is disabled by default. Local benchmarks show close to 1µs and 2 allocs extra overhead from enabling this, without actually using this extra information. This is not part of the logr interface, so you can only use this on the root object.
func (LogSink) WithValues ¶ added in v0.3.0
func (LogSink) WithVerbosity ¶ added in v0.3.0
WithVerbosity returns a new instance with given max verbosity level. This is not part of the logr interface, so you can only use this on the root object.