levels

package
v0.0.0-...-806586e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Levels

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.

Example
package main

import (
	"os"

	"github.com/go-kit/kit/log"
	levels "github.com/go-kit/kit/log/deprecated_levels"
)

func main() {
	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

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

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

func (Levels) Crit

func (l Levels) Crit() log.Logger

Crit returns a critical level logger.

func (Levels) Debug

func (l Levels) Debug() log.Logger

Debug returns a debug level logger.

func (Levels) Error

func (l Levels) Error() log.Logger

Error returns an error level logger.

func (Levels) Info

func (l Levels) Info() log.Logger

Info returns an info level logger.

func (Levels) Warn

func (l Levels) Warn() log.Logger

Warn returns a warning level logger.

func (Levels) With

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

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

type Option

type Option func(*Levels)

Option sets a parameter for leveled loggers.

func CritValue

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

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

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

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

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

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".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL