Documentation ¶
Overview ¶
Package log implements a logging package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SimpleLogger = NewLogger(os.Stdout)
SimpleLogger prints logging information to standard out.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { File string `json:"file" yaml:"file"` Level string `json:"level" yaml:"level"` Fields map[string]interface{} `json:"fields" yaml:"fields"` }
Configuration defines configuration for logging.
func (Configuration) BuildLogger ¶
func (cfg Configuration) BuildLogger() (Logger, error)
BuildLogger builds a new Logger based on the configuration.
type Field ¶
type Field interface { Key() string Value() interface{} }
Field is a single field of additional information passed to the logger.
func NewErrField ¶
NewErrField wraps an error string as a Field named "error".
type Fields ¶
type Fields []Field
Fields is a list of log fields that implements the LoggerFields interface.
type Level ¶
type Level int
Level is the level of logging used by LevelLogger.
The minimum level that will be logged. e.g. LevelError only logs errors and fatals.
func ParseLevel ¶
ParseLevel parses a log level string to log level.
type Logger ¶
type Logger interface { // Enabled returns whether the given level is enabled. Enabled(level Level) bool // Fatalf logs a message, then exits with os.Exit(1). Fatalf(msg string, args ...interface{}) // Fatal logs a message, then exits with os.Exit(1). Fatal(msg string) // Errorf logs a message at error priority. Errorf(msg string, args ...interface{}) // Error logs a message at error priority. Error(msg string) // Warnf logs a message at warning priority. Warnf(msg string, args ...interface{}) // Warn logs a message at warning priority. Warn(msg string) // Infof logs a message at info priority. Infof(msg string, args ...interface{}) // Info logs a message at info priority. Info(msg string) // Debugf logs a message at debug priority. Debugf(msg string, args ...interface{}) // Debug logs a message at debug priority. Debug(msg string) // Fields returns the fields that this logger contains. Fields() LoggerFields // WithFields returns a logger with the current logger's fields and fields. WithFields(fields ...Field) Logger }
Logger provides an abstract interface for logging.
var NullLogger Logger = nullLogger{}
NullLogger is a logger that emits nowhere.
func NewLevelLogger ¶
NewLevelLogger returns a logger that only logs messages with a minimum of level.
type LoggerFields ¶
type LoggerFields interface { // Len returns the length Len() int // ValueAt returns a value for an index. ValueAt(i int) Field }
LoggerFields is a list of Fields used to pass additional information to the logger.