logger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultUserFieldCapacity = 5
View Source
const (
	// The field set by WithError function
	FieldError = "err"
)

Variables

View Source
var AllLevels []Level = []Level{Debug, Info, Warn, Error}

Levels ordered least severe to most severe

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Level   Level
	Message string
	Time    time.Time
	Fields  Fields
}

func (Entry) Color

func (e Entry) Color() *color.Color

type Fields

type Fields map[string]interface{}

type Level

type Level int
const (
	Debug Level = iota
	Info
	Warn
	Error
)

func ParseLevel

func ParseLevel(s string) (l Level, err error)

func (Level) MarshalJSON

func (l Level) MarshalJSON() ([]byte, error)

func (*Level) Set

func (l *Level) Set(s string) error

implement flag.Value implement github.com/spf13/pflag.Value

func (Level) Short

func (l Level) Short() string

func (Level) String

func (l Level) String() string

func (*Level) Type

func (l *Level) Type() string

implement github.com/spf13/pflag.Value

func (*Level) UnmarshalJSON

func (l *Level) UnmarshalJSON(input []byte) (err error)

type Logger

type Logger interface {
	WithOutlet(outlet Outlet, level Level) Logger
	ReplaceField(field string, val interface{}) Logger
	WithField(field string, val interface{}) Logger
	WithFields(fields Fields) Logger
	WithError(err error) Logger
	Debug(msg string)
	Info(msg string)
	Warn(msg string)
	Error(msg string)
	Printf(format string, args ...interface{})
}

func NewLogger

func NewLogger(outlets *Outlets, outletTimeout time.Duration) Logger

func NewNullLogger

func NewNullLogger() Logger

func NewStderrDebugLogger

func NewStderrDebugLogger() Logger

func NewTestLogger

func NewTestLogger(t *testing.T) Logger

type Outlet

type Outlet interface {
	// Write the entry to the destination.
	//
	// Logger waits for all outlets to return from WriteEntry() before returning from the log call.
	// An implementation of Outlet must assert that it does not block in WriteEntry.
	// Otherwise, it will slow down the program.
	//
	// Note: os.Stderr is also used by logger.Logger for reporting errors returned by outlets
	//       => you probably don't want to log there
	WriteEntry(entry Entry) error
}

An outlet receives log entries produced by the Logger and writes them to some destination.

type Outlets

type Outlets struct {
	// contains filtered or unexported fields
}

func NewOutlets

func NewOutlets() *Outlets

func (*Outlets) Add

func (os *Outlets) Add(outlet Outlet, minLevel Level)

func (*Outlets) DeepCopy

func (os *Outlets) DeepCopy() (copy *Outlets)

func (*Outlets) Get

func (os *Outlets) Get(level Level) []Outlet

func (*Outlets) GetLoggerErrorOutlet

func (os *Outlets) GetLoggerErrorOutlet() Outlet

Return the first outlet added to this Outlets list using Add() with minLevel <= Error. If no such outlet is in this Outlets list, a discarding outlet is returned.

Jump to

Keyboard shortcuts

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