logger

package
v0.0.0-...-fd2130c Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const LevelDebug = 20
View Source
const LevelDebugCall = 15
View Source
const LevelError = 50

LevelError is the level for user visible error

View Source
const LevelFatal = 60

LevelFatal is the level for panic or panic like scenario

View Source
const LevelInfo = 30

LevelInfo should be the production environment default

View Source
const LevelInfoCall = 25
View Source
const LevelTrace = 10

LevelTrace should be development environment default

View Source
const LevelTraceCall = 5

LevelTraceCall is lowest logging level enable this will print every TraceCall, which is a LOT

View Source
const LevelWarn = 40

LevelWarn is the level for error != nil

Variables

View Source
var ErrorLogger = log.New(os.Stderr, "", 0)
View Source
var LogContextKey = 1010010001
View Source
var MinCallLevel = LevelDebugCall

MinCallLevel will be half level higher than MinLevel to minimize the xxxCall output

View Source
var MinLevel = LevelTrace

MinLevel exists to minimize the overhead of Trace/Debug logging

Functions

func ColoredLevelName

func ColoredLevelName(level int) string

func LevelName

func LevelName(level int) string

func WithLogContext

func WithLogContext(ctx context.Context) context.Context

Types

type DummyEventHandler

type DummyEventHandler struct {
	Site *LogSite
}

func (*DummyEventHandler) Handle

func (handler *DummyEventHandler) Handle(event *Event)

func (*DummyEventHandler) LogSite

func (handler *DummyEventHandler) LogSite() *LogSite

type Event

type Event struct {
	Level      int
	Context    context.Context
	Error      error
	Timestamp  time.Time
	Properties []interface{}
}

type EventHandler

type EventHandler interface {
	Handle(event *Event)
	LogSite() *LogSite
}

type EventHandlers

type EventHandlers []EventHandler

func (EventHandlers) Handle

func (handlers EventHandlers) Handle(event *Event)

func (EventHandlers) LogSite

func (handlers EventHandlers) LogSite() *LogSite

type EventSink

type EventSink interface {
	HandlerOf(site *LogSite) EventHandler
}

type FuncEventHandler

type FuncEventHandler func(event *Event)

func (FuncEventHandler) Handle

func (handler FuncEventHandler) Handle(event *Event)

func (FuncEventHandler) LogSite

func (handler FuncEventHandler) LogSite() *LogSite

type FuncEventSink

type FuncEventSink func(site *LogSite) EventHandler

func (FuncEventSink) HandlerOf

func (sink FuncEventSink) HandlerOf(site *LogSite) EventHandler

type LogContext

type LogContext struct {
	Memos      [][]byte
	Properties []interface{}
}

func GetLogContext

func GetLogContext(ctx context.Context) *LogContext

func (*LogContext) Add

func (ctx *LogContext) Add(key string, value interface{})

type LogSite

type LogSite struct {
	Context context.Context
	Func    string
	File    string
	Line    int
	Event   string
	Agg     string
	Sample  []interface{}
}

LogSite is the location of log in the source code

func (*LogSite) Location

func (site *LogSite) Location() string

func (*LogSite) LogContext

func (site *LogSite) LogContext() *LogContext

type Memo

type Memo struct {
	Site  *LogSite
	Event *Event
}

Jump to

Keyboard shortcuts

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