Documentation ¶
Index ¶
- Variables
- func AddHandler(handler Handler, levels ...Level)
- func AddHook(hook Hookfunc) error
- func Debug(msg string)
- func Debugf(msg string, v ...interface{})
- func Error(msg string)
- func Errorf(msg string, v ...interface{})
- func Fatal(msg string)
- func Fatalf(msg string, v ...interface{})
- func Flush()
- func Info(msg string)
- func Infof(msg string, v ...interface{})
- func Panic(msg string)
- func Panicf(msg string, v ...interface{})
- func RemoveAllHandlers()
- func Warn(msg string)
- func Warnf(msg string, v ...interface{})
- type Context
- func Bool(key string, val bool) Context
- func Err(err error) Context
- func Float32(key string, val float32) Context
- func Float64(key string, val float64) Context
- func FromContext(ctx context.Context) Context
- func Int(key string, val int) Context
- func Int16(key string, val int16) Context
- func Int32(key string, val int32) Context
- func Int64(key string, val int64) Context
- func Int8(key string, val int8) Context
- func Str(key string, val string) Context
- func Uint(key string, val uint) Context
- func Uint16(key string, val uint16) Context
- func Uint32(key string, val uint32) Context
- func Uint64(key string, val uint64) Context
- func Uint8(key string, val uint8) Context
- func (c Context) Bool(key string, val bool) Context
- func (c Context) Debug(msg string)
- func (c Context) Debugf(msg string, v ...interface{})
- func (c Context) Err(err error) Context
- func (c Context) Error(msg string)
- func (c Context) Errorf(msg string, v ...interface{})
- func (c Context) Fatal(msg string)
- func (c Context) Fatalf(msg string, v ...interface{})
- func (c Context) Float32(key string, val float32) Context
- func (c Context) Float64(key string, val float64) Context
- func (c Context) Info(msg string)
- func (c Context) Infof(msg string, v ...interface{})
- func (c Context) Int(key string, val int) Context
- func (c Context) Int16(key string, val int16) Context
- func (c Context) Int32(key string, val int32) Context
- func (c Context) Int64(key string, val int64) Context
- func (c Context) Int8(key string, val int8) Context
- func (c Context) Interface(key string, val interface{}) Context
- func (c Context) Ints(key string, val []int) Context
- func (c Context) Panic(msg string)
- func (c Context) Panicf(msg string, v ...interface{})
- func (c Context) SaveToDefault()
- func (c Context) StackTrace() Context
- func (c Context) Str(key string, val string) Context
- func (c Context) Strs(key string, val []string) Context
- func (c Context) Time(key string, val time.Time) Context
- func (c Context) Times(key string, val []time.Time) Context
- func (c Context) Uint(key string, val uint) Context
- func (c Context) Uint16(key string, val uint16) Context
- func (c Context) Uint32(key string, val uint32) Context
- func (c Context) Uint64(key string, val uint64) Context
- func (c Context) Uint8(key string, val uint8) Context
- func (c Context) Warn(msg string)
- func (c Context) Warnf(msg string, v ...interface{})
- func (c Context) WithContext(ctx context.Context) context.Context
- type Entry
- func (e *Entry) Bool(key string, val bool) *Entry
- func (e *Entry) Debug(msg string)
- func (e *Entry) Debugf(msg string, v ...interface{})
- func (e *Entry) Dur(key string, d time.Duration) *Entry
- func (e *Entry) Error(msg string)
- func (e *Entry) Errorf(msg string, v ...interface{})
- func (e *Entry) Fatal(msg string)
- func (e *Entry) Fatalf(msg string, v ...interface{})
- func (e *Entry) Float32(key string, val float32) *Entry
- func (e *Entry) Float64(key string, val float64) *Entry
- func (e *Entry) Info(msg string)
- func (e *Entry) Infof(msg string, v ...interface{})
- func (e *Entry) Int(key string, val int) *Entry
- func (e *Entry) Int16(key string, val int16) *Entry
- func (e *Entry) Int32(key string, val int32) *Entry
- func (e *Entry) Int64(key string, val int64) *Entry
- func (e *Entry) Int8(key string, val int8) *Entry
- func (e *Entry) Interface(key string, val interface{}) *Entry
- func (e *Entry) Ints(key string, val []int) *Entry
- func (e *Entry) Panic(msg string)
- func (e *Entry) Panicf(msg string, v ...interface{})
- func (e *Entry) StackTrace() *Entry
- func (e *Entry) Stop()
- func (e *Entry) Str(key string, val string) *Entry
- func (e *Entry) Strs(key string, val []string) *Entry
- func (e *Entry) Time(key string, val time.Time) *Entry
- func (e *Entry) Times(key string, val []time.Time) *Entry
- func (e *Entry) Trace(msg string) *Entry
- func (e *Entry) Uint(key string, val uint) *Entry
- func (e *Entry) Uint16(key string, val uint16) *Entry
- func (e *Entry) Uint32(key string, val uint32) *Entry
- func (e *Entry) Uint64(key string, val uint64) *Entry
- func (e *Entry) Uint8(key string, val uint8) *Entry
- func (e *Entry) Warn(msg string)
- func (e *Entry) Warnf(msg string, v ...interface{})
- type Flusher
- type Handler
- type Hookfunc
- type Level
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorHandler is called whenever handler fails to write an event on its // output. If not set, an error is printed on the stderr. This handler must // be thread safe and non-blocking. ErrorHandler func(err error) // AutoStaceTrace add stack trace into entry when use `Error`, `Panic`, `Fatal` level. // Default: true AutoStaceTrace = true )
Logger is the default instance of the log package
var AllLevels = []Level{ DebugLevel, InfoLevel, WarnLevel, ErrorLevel, PanicLevel, FatalLevel, TraceLevel, }
AllLevels is an array of all log levels, for easier registering of all levels to a handler
Functions ¶
func AddHandler ¶
AddHandler adds a new Log Handler and specifies what log levels the handler will be passed log entries for
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context use for meta data
func FromContext ¶
FromContext return a log context from the standard context
func (Context) SaveToDefault ¶
func (c Context) SaveToDefault()
SaveToDefault save the current context to default logger and these context to be printed with every entry
func (Context) StackTrace ¶
StackTrace adds stack_trace field to the current context
type Entry ¶
type Entry struct { Level Level `json:"level"` Message string `json:"message"` // contains filtered or unexported fields }
Entry defines a single log entry
func Trace ¶
Trace returns a new entry with a Stop method to fire off a corresponding completion log, useful with defer.
func (*Entry) StackTrace ¶
StackTrace adds stack_trace field to the current context
func (*Entry) Stop ¶
func (e *Entry) Stop()
Stop should be used with Trace, to fire off the completion message. When an `err` is passed the "error" field is set, and the log level is error.
func (*Entry) Trace ¶
Trace returns a new entry with a Stop method to fire off a corresponding completion log, useful with defer.
type Flusher ¶
type Flusher interface {
Flush() error
}
Flusher is an interface that allow handles have the ability to clear buffer and close connection
type Level ¶
type Level uint8
Level of the log
Log levels.
func GetLevelsFromMinLevel ¶
GetLevelsFromMinLevel returns Levels array which above minLevel
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
handlers
|
|
discard
Package discard implements a no-op handler useful for benchmarks and tests.
|
Package discard implements a no-op handler useful for benchmarks and tests. |
memory
Package memory implements an in-memory handler useful for testing, as the entries can be accessed after writes.
|
Package memory implements an in-memory handler useful for testing, as the entries can be accessed after writes. |
internal
|
|