kit: github.com/go-kit/kit/log/deprecated_levels Index | Examples | Files

package levels

import "github.com/go-kit/kit/log/deprecated_levels"

Index

Examples

Package Files

levels.go

type Levels Uses

type Levels struct {
    // contains filtered or unexported fields
}

Levels provides a leveled logging wrapper around a logger. It has five levels: debug, info, warning (warn), error, and critical (crit). If you want a different set of levels, you can create your own levels type very easily, and you can elide the configuration.

Code:

logger := levels.New(log.NewLogfmtLogger(os.Stdout))
logger.Debug().Log("msg", "hello")
logger.With("context", "foo").Warn().Log("err", "error")

Output:

level=debug msg=hello
level=warn context=foo err=error

func New Uses

func New(logger log.Logger, options ...Option) Levels

New creates a new leveled logger, wrapping the passed logger.

func (Levels) Crit Uses

func (l Levels) Crit() log.Logger

Crit returns a critical level logger.

func (Levels) Debug Uses

func (l Levels) Debug() log.Logger

Debug returns a debug level logger.

func (Levels) Error Uses

func (l Levels) Error() log.Logger

Error returns an error level logger.

func (Levels) Info Uses

func (l Levels) Info() log.Logger

Info returns an info level logger.

func (Levels) Warn Uses

func (l Levels) Warn() log.Logger

Warn returns a warning level logger.

func (Levels) With Uses

func (l Levels) With(keyvals ...interface{}) Levels

With returns a new leveled logger that includes keyvals in all log events.

type Option Uses

type Option func(*Levels)

Option sets a parameter for leveled loggers.

func CritValue Uses

func CritValue(value string) Option

CritValue sets the value for the field used to indicate the critical log level. By default, the value is "crit".

func DebugValue Uses

func DebugValue(value string) Option

DebugValue sets the value for the field used to indicate the debug log level. By default, the value is "debug".

func ErrorValue Uses

func ErrorValue(value string) Option

ErrorValue sets the value for the field used to indicate the error log level. By default, the value is "error".

func InfoValue Uses

func InfoValue(value string) Option

InfoValue sets the value for the field used to indicate the info log level. By default, the value is "info".

func Key Uses

func Key(key string) Option

Key sets the key for the field used to indicate log level. By default, the key is "level".

func WarnValue Uses

func WarnValue(value string) Option

WarnValue sets the value for the field used to indicate the warning log level. By default, the value is "warn".

Package levels imports 1 packages (graph). Updated 2017-03-07. Refresh now. Tools for package owners.