log

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLogLevel Level = ErrorLevel

	DefaultLogger Logger = &logger{
		logLevel: &DefaultLogLevel,
		writer:   defaultWriter,
		output:   defaultOutput,
	}
)

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

func Any

func Any(k string, v interface{}) Field

func Bool

func Bool(k string, v bool) Field

func Error

func Error(v error) Field

func Int

func Int(k string, v int) Field

func Stack

func Stack() Field

func String

func String(k, v string) Field

func Strings

func Strings(k string, v []string) Field

type Level

type Level int8
const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

type Logger

type Logger interface {
	SetOutput(w io.Writer)
	With(fields ...Field) Logger
	Named(name string) Logger
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
	Panic(msg string, fields ...Field)
	Fatal(msg string, fields ...Field)
}

func FromContext

func FromContext(ctx context.Context) Logger

func New added in v0.11.4

func New() Logger

type Writer

type Writer func(log *logger, level Level, msg string, extraFields ...Field)

func JSONWriter

func JSONWriter() Writer

func StringWriter

func StringWriter() Writer

Jump to

Keyboard shortcuts

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