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 Info(msg string)
- func Infof(msg string, v ...interface{})
- func SetHandler(h Handler)
- func SetLevel(level Level)
- func Warn(msg string)
- func Warnf(msg string, v ...interface{})
- type Entry
- type Fielder
- type Fields
- type Handler
- type HandlerFunc
- type Level
- type Logger
- func (l *Logger) Debug(msg string)
- func (l *Logger) Debugf(msg string, v ...interface{})
- func (l *Logger) Error(msg string)
- func (l *Logger) Errorf(msg string, v ...interface{})
- func (l *Logger) Fatal(msg string)
- func (l *Logger) Fatalf(msg string, v ...interface{})
- func (l *Logger) Info(msg string)
- func (l *Logger) Infof(msg string, v ...interface{})
- func (l *Logger) Log(level Level, msg string)
- func (l *Logger) Logf(level Level, msg string, v ...interface{})
- func (l *Logger) Warn(msg string)
- func (l *Logger) Warnf(msg string, v ...interface{})
- func (l *Logger) WithError(err error) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields Fields) *Logger
- func (l *Logger) WithLevel(level Level) *Logger
Constants ¶
This section is empty.
Variables ¶
var Log = &Logger{ Level: InfoLevel, }
Log is singleton commonly used as the root logger.
Functions ¶
Types ¶
type Entry ¶
type Entry struct { Fields Fields `json:"fields"` Level Level `json:"level"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` }
Entry represents a single log entry.
type Fielder ¶
type Fielder interface {
Fields() Fields
}
Fielder is an interface for providing fields to custom types.
type Fields ¶
type Fields map[string]interface{}
Fields represents a map of entry level data used for structured logging.
type Handler ¶
Handler is used to handle log events, outputting them to stdio or sending them to remote services. See the "handlers" directory for implementations.
It is left up to Handlers to implement thread-safety.
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of ordinary functions as log handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object that calls f.
type Level ¶
type Level int
Level of severity.
func (Level) MarshalJSON ¶
MarshalJSON returns the level string.
func (Level) MarshalText ¶
MarshalText marshals the level to a string.
func (*Level) UnmarshalJSON ¶
UnmarshalJSON returns the level from the string.
func (*Level) UnmarshalText ¶
UnmarshalText returns a level from a string.
type Logger ¶
Logger represents a logger with configurable Level and Handler.
func WithFields ¶
WithFields returns a new logger with `fields` set.
func (*Logger) WithFields ¶
WithFields returns a new logger with `fields` set.
Directories
¶
Path | Synopsis |
---|---|
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. |
json
Package json implements a JSON handler.
|
Package json implements a JSON handler. |
text
Package text implements a development-friendly textual handler.
|
Package text implements a development-friendly textual handler. |