Documentation ¶
Index ¶
- Variables
- 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 NewContext(ctx context.Context, e Entry) context.Context
- func Panic(msg string)
- func Panicf(msg string, v ...interface{})
- func RegisterHandler(handler Handler, levels ...Level)
- func Warn(msg string)
- func Warnf(msg string, v ...interface{})
- func WithDefaultFields(fields Fields)
- type Entry
- func Bool(key string, val bool) Entry
- func Float32(key string, val float32) Entry
- func Float64(key string, val float64) Entry
- func FromContext(ctx context.Context) Entry
- func Int(key string, val int) Entry
- func Int16(key string, val int16) Entry
- func Int32(key string, val int32) Entry
- func Int64(key string, val int64) Entry
- func Int8(key string, val int8) Entry
- func Str(key string, val string) Entry
- func Trace(msg string) Entry
- func Uint(key string, val uint) Entry
- func Uint16(key string, val uint16) Entry
- func Uint32(key string, val uint32) Entry
- func Uint64(key string, val uint64) Entry
- func Uint8(key string, val uint8) Entry
- func WithError(err error) Entry
- func WithField(key string, value interface{}) Entry
- func WithFields(fields Fields) 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) 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) Panic(msg string)
- func (e Entry) Panicf(msg string, v ...interface{})
- func (e Entry) Stop()
- func (e Entry) Str(key string, val string) 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{})
- func (e Entry) WithError(err error) Entry
- func (e Entry) WithField(key string, value interface{}) Entry
- func (e Entry) WithFields(fields Fields) Entry
- type Fields
- type Flusher
- type Handler
- type Level
Constants ¶
This section is empty.
Variables ¶
var AllLevels = []Level{ DebugLevel, InfoLevel, WarnLevel, ErrorLevel, PanicLevel, FatalLevel, }
AllLevels is an array of all log levels, for easier registering of all levels to a handler
Functions ¶
func Fatalf ¶
func Fatalf(msg string, v ...interface{})
Fatalf level formatted message, followed by an exit.
func NewContext ¶
NewContext return a new context with a logger value
func RegisterHandler ¶
RegisterHandler adds a new Log Handler and specifies what log levels the handler will be passed log entries for
func WithDefaultFields ¶
func WithDefaultFields(fields Fields)
WithDefaultFields adds fields to every entry instance
Types ¶
type Entry ¶
type Entry struct { Level Level `json:"level"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` Fields Fields `json:"fields"` // single map; easy to use for handlers // contains filtered or unexported fields }
Entry defines a single log entry
func FromContext ¶
FromContext return a logger from the context
func Trace ¶
Trace returns a new entry with a Stop method to fire off a corresponding completion log, useful with defer.
func WithFields ¶
WithFields returns a log Entry with fields set
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.
func (Entry) WithFields ¶
WithFields adds the provided fields to the current entry
type Fields ¶
type Fields map[string]interface{}
Fields represents a map of entry level data used for structured logging.
type Flusher ¶ added in v1.0.1
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
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. |