func New(std StdLogger) logr.Logger
New returns a logr.Logger which is implemented by Go's standard log package, or something like it. If std is nil, this will use a default logger instead.
Example: stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile)))
▹ Example
▹ Example (WithName)
func NewWithOptions(std StdLogger, opts Options) logr.Logger
NewWithOptions returns a logr.Logger which is implemented by Go's standard log package, or something like it. See New for details.
▹ Example
func SetVerbosity(v int) int
SetVerbosity sets the global level against which all info logs will be compared. If this is greater than or equal to the "V" of the logger, the message will be logged. A higher value here means more logs will be written. The previous verbosity value is returned. This is not concurrent-safe - callers must be sure to call it from only one goroutine.
MessageClass indicates which category or categories of messages to consider.
type MessageClass int
const ( // None ignores all message classes. None MessageClass = iota // All considers all message classes. All // Info only considers info messages. Info // Error only considers error messages. Error )
Options carries parameters which influence the way logs are generated.
type Options struct { // Depth biases the assumed number of call frames to the "true" caller. // This is useful when the calling code calls a function which then calls // stdr (e.g. a logging shim to another API). Values less than zero will // be treated as zero. Depth int // LogCaller tells stdr to add a "caller" key to some or all log lines. // Go's log package has options to log this natively, too. LogCaller MessageClass }
StdLogger is the subset of the Go stdlib log.Logger API that is needed for this adapter.
type StdLogger interface { // Output is the same as log.Output and log.Logger.Output. Output(calldepth int, logline string) error }
Underlier exposes access to the underlying logging implementation. Since callers only have a logr.Logger, they have to know which implementation is in use, so this interface is less of an abstraction and more of way to test type conversion.
type Underlier interface { GetUnderlying() StdLogger }