levels

package
v0.0.0-...-3978dae Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2015 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"
	"github.com/go-kit/kit/log/levels"
)

func main() {
	logger := levels.New(log.NewLogfmtLogger(os.Stdout))
	logger.Debug("msg", "hello")
	logger.With("context", "foo").Warn("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(keyvals ...interface{}) error

Crit logs a crit event along with keyvals.

func (Levels) Debug

func (l Levels) Debug(keyvals ...interface{}) error

Debug logs a debug event along with keyvals.

func (Levels) Error

func (l Levels) Error(keyvals ...interface{}) error

Error logs an error event along with keyvals.

func (Levels) Info

func (l Levels) Info(keyvals ...interface{}) error

Info logs an info event along with keyvals.

func (Levels) Warn

func (l Levels) Warn(keyvals ...interface{}) error

Warn logs a warn event along with keyvals.

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