level

package
v0.0.0-...-1ac3849 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

This is a modified version of the go-kit/kit/log/level package to fit godin's need.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(logger log.Logger) log.Logger

Debug returns a logger that includes a Key/DebugValue pair.

func Error

func Error(logger log.Logger) log.Logger

Error returns a logger that includes a Key/ErrorValue pair.

func Info

func Info(logger log.Logger) log.Logger

Info returns a logger that includes a Key/InfoValue pair.

func Key

func Key() interface{}

Key returns the unique key added to log events by the loggers in this package.

func NewFilter

func NewFilter(next log.Logger, options ...Option) log.Logger

NewFilter wraps next and implements level filtering. See the commentary on the Option functions for a detailed description of how to configure levels. If no options are provided, all leveled log events created with Debug, Info, Warn or Error helper methods are squelched and non-leveled log events are passed to next unmodified.

func NewInjector

func NewInjector(next log.Logger, level Value) log.Logger

NewInjector wraps next and returns a logger that adds a Key/level pair to the beginning of log events that don't already contain a level. In effect, this gives a default level to logs without a level.

func Warn

func Warn(logger log.Logger) log.Logger

Warn returns a logger that includes a Key/WarnValue pair.

Types

type Option

type Option func(*logger)

Option sets a parameter for the leveled logger.

func AllowAll

func AllowAll() Option

AllowAll is an alias for AllowDebug.

func AllowDebug

func AllowDebug() Option

AllowDebug allows error, warn, info and debug level log events to pass.

func AllowError

func AllowError() Option

AllowError allows only error level log events to pass.

func AllowInfo

func AllowInfo() Option

AllowInfo allows error, warn and info level log events to pass.

func AllowNone

func AllowNone() Option

AllowNone allows no leveled log events to pass.

func AllowWarn

func AllowWarn() Option

AllowWarn allows error and warn level log events to pass.

func ErrNoLevel

func ErrNoLevel(err error) Option

ErrNoLevel sets the error to return from Log when it squelches a log event with no level. By default, ErrNoLevel is nil; in this case the log event is squelched with no error.

func ErrNotAllowed

func ErrNotAllowed(err error) Option

ErrNotAllowed sets the error to return from Log when it squelches a log event disallowed by the configured Allow[Level] option. By default, ErrNotAllowed is nil; in this case the log event is squelched with no error.

func SquelchNoLevel

func SquelchNoLevel(squelch bool) Option

SquelchNoLevel instructs Log to squelch log events with no level, so that they don't proceed through to the wrapped logger. If SquelchNoLevel is set to true and a log event is squelched in this way, the error value configured with ErrNoLevel is returned to the caller.

type Value

type Value interface {
	String() string
	// contains filtered or unexported methods
}

Value is the interface that each of the canonical level values implement. It contains unexported methods that prevent types from other packages from implementing it and guaranteeing that NewFilter can distinguish the levels defined in this package from all other values.

func DebugValue

func DebugValue() Value

DebugValue returns the unique value added to log events by Warn.

func ErrorValue

func ErrorValue() Value

ErrorValue returns the unique value added to log events by Error.

func InfoValue

func InfoValue() Value

InfoValue returns the unique value added to log events by Info.

func WarnValue

func WarnValue() Value

WarnValue returns the unique value added to log events by Warn.

Jump to

Keyboard shortcuts

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