stdr – github.com/go-logr/stdr Index | Files | Directories

package stdr

import "github.com/go-logr/stdr"

Package strd implements github.com/go-logr/logr.Logger in terms of Go's standard log package.

Index

Functions

func New

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 call functions in the log package instead.

Example: stdr.New(log.New(os.Stderr, "", log.LstdFlags)))

func NewWithOptions

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.

func SetVerbosity

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.

Types

type Options

type Options struct {
	// DepthOffset biases the assumed number of call frames to the "true"
	// caller.  This is useful when the calling code calls a function which then
	// calls glogr (e.g. a logging shim to another API).  Values less than zero
	// will be treated as zero.
	Depth int
}

type StdLogger

type StdLogger interface {
	// Output is the same as log.Output and log.Logger.Output.
	Output(calldepth int, logline string) error
}

StdLogger is the subset of the Go stdlib log.Logger API that is needed for this adapter.

Source Files

stdr.go

Directories

PathSynopsis
example
Version
v0.2.0
Published
Jun 11, 2020
Platform
js/wasm
Imports
7 packages
Last checked
now

Tools for package owners.