Documentation ¶
Overview ¶
Package log provids a severity-based key/value logging replacement for Go's standard logger.
The output is a simple and clean logging format that strikes the perfect balance between being human readable and easy to write parsing tools for.
Examples:
ERROR | MyLibrary | Could not connect to server. | url='http://timehop.com/' error='timed out' INFO | MyLibrary | Something happened.
Index ¶
- Constants
- func Debug(id, description string, keysAndValues ...interface{})
- func Error(id, description string, keysAndValues ...interface{})
- func Fatal(id, description string, keysAndValues ...interface{})
- func Info(id, description string, keysAndValues ...interface{})
- func SetLevel(level LogLevel)
- func SetOutput(w io.Writer)
- func SetPrefix(prefix string)
- func SetStackTrace(trace bool)
- func SetTimestampFlags(flags int)
- func Trace(id, description string, keysAndValues ...interface{})
- func Warn(id, description string, keysAndValues ...interface{})
- type Config
- type LogFormat
- type LogLevel
- type LogLevelName
- type Logger
Constants ¶
const ( FlagsNone = 0 FlagsDate = log.Ldate FlagsTime = log.Ltime FlagsPrecisionTime = log.Lmicroseconds FlagsLongFile = log.Llongfile FlagsShortFile = log.Lshortfile FlagsDefault = log.LstdFlags )
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(id, description string, keysAndValues ...interface{})
Debug outputs an info message with an optional list of key/value pairs.
If LogLevel is set below LevelDebug, calling this method will yield no side effects.
func Error ¶
func Error(id, description string, keysAndValues ...interface{})
Error outputs an error message with an optional list of key/value pairs.
func Fatal ¶
func Fatal(id, description string, keysAndValues ...interface{})
Fatal outputs a severe error message just before terminating the process. Use judiciously.
func Info ¶
func Info(id, description string, keysAndValues ...interface{})
Info outputs an info message with an optional list of key/value pairs.
If LogLevel is set below LevelInfo, calling this method will yield no side effects.
func SetOutput ¶
SetOutput sets the output destination for the default logger.
All new logger instances created after this call will use the provided io.Writer as destination for their output.
If you specifically want to change the output of DefaultLogger and not affect new Logger instance creation, use log.DefaultLogger.SetOutput()
func SetPrefix ¶
func SetPrefix(prefix string)
Changes the global prefix for all log statements.
New logger instances created after this method is called will be affected. Prefix is useful for multi-tail scenarios (tailing logs across multiple machines, to help distinguish which is which.)
func SetStackTrace ¶
func SetStackTrace(trace bool)
func SetTimestampFlags ¶
func SetTimestampFlags(flags int)
SetFlags changes the timestamp flags on the output of the default logger.
Types ¶
type LogLevelName ¶
type LogLevelName string
const ( LevelFatalName LogLevelName = "FATAL" LevelErrorName LogLevelName = "ERROR" LevelWarnName LogLevelName = "WARN" LevelInfoName LogLevelName = "INFO" LevelDebugName LogLevelName = "DEBUG" LevelTraceName LogLevelName = "TRACE" )
type Logger ¶
type Logger interface { Fatal(description string, keysAndValues ...interface{}) Error(description string, keysAndValues ...interface{}) Warn(description string, keysAndValues ...interface{}) Info(description string, keysAndValues ...interface{}) Debug(description string, keysAndValues ...interface{}) Trace(description string, keysAndValues ...interface{}) SetLevel(level LogLevel) SetOutput(w io.Writer) SetTimestampFlags(flags int) SetStaticField(name string, value interface{}) SetStackTrace(trace bool) }
var (
DefaultLogger Logger
)
func NewDefault ¶
func NewDefault() Logger