Documentation
¶
Overview ¶
Package funcr implements formatting of structured log messages and optionally captures the call site and timestamp.
The simplest way to use it is via its implementation of a github.com/go-logr/logr.LogSink with output through an arbitrary "write" function. See New and NewJSON for details.
Custom LogSinks ¶
For users who need more control, a funcr.Formatter can be embedded inside your own custom LogSink implementation. This is useful when the LogSink needs to implement additional methods, for example.
Formatting ¶
This will respect logr.Marshaler, fmt.Stringer, and error interfaces for values which are being logged. When rendering a struct, funcr will use Go's standard JSON tags (all except "string").
Index ¶
- func New(fn func(prefix, args string), opts Options) logr.Logger
- func NewJSON(fn func(obj string), opts Options) logr.Logger
- type Caller
- type Formatter
- func (f *Formatter) AddCallDepth(depth int)
- func (f *Formatter) AddName(name string)
- func (f *Formatter) AddValues(kvList []any)
- func (f Formatter) Enabled(level int) bool
- func (f Formatter) FormatError(err error, msg string, kvList []any) (prefix, argsStr string)
- func (f Formatter) FormatInfo(level int, msg string, kvList []any) (prefix, argsStr string)
- func (f Formatter) GetDepth() int
- func (f *Formatter) Init(info logr.RuntimeInfo)
- type MessageClass
- type Options
- type PseudoStruct
- type Underlier
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.