log

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLogLevel Level     = ErrorLevel
	DefaultOutput   io.Writer = os.Stdout
	DefaultWriter   Writer    = JSONWriter()
	DefaultLogger   Logger    = &logger{
		writer: DefaultWriter,
		output: DefaultOutput,
	}
)

Functions

func FromContext

func FromContext(ctx context.Context) *logger

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 {
	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)
}

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