Documentation ¶
Overview ¶
Package log provides support for structured logging.
Index ¶
- Constants
- func AtDebug() bool
- func AtError() bool
- func AtInfo() bool
- func AtStackTrace() bool
- func AtWarn() bool
- func Debug(text string, fields ...Field)
- func Debugf(format string, args ...interface{})
- func Error(text string, fields ...Field)
- func Errorf(format string, args ...interface{})
- func Fatal(text string, fields ...Field)
- func Fatalf(format string, args ...interface{})
- func Info(text string, fields ...Field)
- func Infof(format string, args ...interface{})
- func SetGlobal(fields ...Field)
- func StackTrace(text string)
- func ToConsole(lvl Level)
- func ToFile(path string, lvl Level) error
- func ToServer(addr string, lvl Level, limit int)
- func Warn(text string, fields ...Field)
- func Warnf(format string, args ...interface{})
- type Field
- func Bool(key string, value bool) Field
- func Bools(key string, value []bool) Field
- func Bytes(key string, value []byte) Field
- func BytesArray(key string, value [][]byte) Field
- func Digest(key string, value []byte) Field
- func Digests(key string, value [][]byte) Field
- func Duration(key string, value time.Duration) Field
- func Durations(key string, value []time.Duration) Field
- func Err(value error) Field
- func Errs(value error) Field
- func Float32(key string, value float32) Field
- func Float32s(key string, value []float32) Field
- func Float64(key string, value float64) Field
- func Float64s(key string, value []float64) Field
- func Int(key string, value int) Field
- func Int16(key string, value int16) Field
- func Int16s(key string, value []int16) Field
- func Int32(key string, value int32) Field
- func Int32s(key string, value []int32) Field
- func Int64(key string, value int64) Field
- func Int64s(key string, value []int64) Field
- func Int8(key string, value int8) Field
- func Int8s(key string, value []int8) Field
- func Ints(key string, value []int) Field
- func String(key string, value string) Field
- func Strings(key string, value []string) Field
- func Time(key string, value time.Time) Field
- func Times(key string, value []time.Time) Field
- func Uint(key string, value uint) Field
- func Uint16(key string, value uint16) Field
- func Uint16s(key string, value []uint16) Field
- func Uint32(key string, value uint32) Field
- func Uint32s(key string, value []uint32) Field
- func Uint64(key string, value uint64) Field
- func Uint64s(key string, value []uint64) Field
- func Uint8(key string, value uint8) Field
- func Uint8s(key string, value []uint8) Field
- func Uints(key string, value []uint) Field
- type Level
- type Logger
- func (l *Logger) Debug(text string, fields ...Field)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(text string, fields ...Field)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(text string, fields ...Field)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(text string, fields ...Field)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) StackTrace(text string)
- func (l *Logger) Warn(text string, fields ...Field)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) With(fields ...Field) *Logger
- type Server
Constants ¶
const ( TypeBool fieldType = iota + 1 TypeBools TypeBytes TypeBytesArray TypeDigest TypeDigests TypeDuration TypeDurations TypeErr TypeErrs TypeFloat32 TypeFloat32s TypeFloat64 TypeFloat64s TypeInt TypeInts TypeInt8 TypeInt8s TypeInt16 TypeInt16s TypeInt32 TypeInt32s TypeInt64 TypeInt64s TypeString TypeStrings TypeTime TypeTimes TypeUint TypeUints TypeUint8 TypeUint8s TypeUint16 TypeUint16s TypeUint32 TypeUint32s TypeUint64 TypeUint64s )
Log field types.
Variables ¶
This section is empty.
Functions ¶
func AtDebug ¶
func AtDebug() bool
AtDebug returns whether the current configuration will log at the DebugLevel.
func AtError ¶
func AtError() bool
AtError returns whether the current configuration will log at the ErrorLevel.
func AtInfo ¶
func AtInfo() bool
AtInfo returns whether the current configuration will log at the InfoLevel.
func AtStackTrace ¶
func AtStackTrace() bool
AtStackTrace returns whether the current configuration will log at the StackTraceLevel.
func AtWarn ¶
func AtWarn() bool
AtWarn returns whether the current configuration will log at the WarnLevel.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf formats similarly to Printf and logs the resulting output at the DebugLevel using the root logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf formats similarly to Printf and logs the resulting output at the ErrorLevel using the root logger.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf formats similarly to Printf and logs the resulting output at the FatalLevel using the root logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof formats similarly to Printf and logs the resulting output at the InfoLevel using the root logger.
func SetGlobal ¶
func SetGlobal(fields ...Field)
SetGlobal sets the given fields on the root logger. SetGlobal is not threadsafe, so should be set before any goroutines that make log calls.
func StackTrace ¶
func StackTrace(text string)
StackTrace logs the given text at StackTraceLevel along with the stacktrace using the root logger.
func ToConsole ¶
func ToConsole(lvl Level)
ToConsole sets the log level of the console logger. By default it will be logging at DebugLevel until this function is used to change the setting.
func ToServer ¶
ToServer starts logging to the given server. It starts dropping backfilled entries beyond the given limit.
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a key/value pair for adding to a log entry.
func BytesArray ¶
BytesArray represents a field with an array of byte slice values.
func Err ¶
Err represents a field with an error value. It automatically uses "error" as the Field key.
func Errs ¶
Errs represents a field with an array of error values. It automatically uses "error" as the Field key.
type Level ¶
type Level int8
Level represents a logging level.
Logging levels.
func (Level) MarshalYAML ¶
MarshalYAML implements the YAML encoding interface.
func (*Level) UnmarshalYAML ¶
UnmarshalYAML implements the YAML decoding interface.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger encapsulates the state of a logger with custom fields.
func With ¶
With returns a new logger based off of the root logger that comes preset with the given fields.
func (*Logger) Debugf ¶
Debugf formats similarly to Printf and logs the resulting output at the DebugLevel.
func (*Logger) Errorf ¶
Errorf formats similarly to Printf and logs the resulting output at the ErrorLevel.
func (*Logger) Fatalf ¶
Fatalf formats similarly to Printf and logs the resulting output at the FatalLevel.
func (*Logger) Infof ¶
Infof formats similarly to Printf and logs the resulting output at the InfoLevel.
func (*Logger) StackTrace ¶
StackTrace logs the given text at StackTraceLevel along with the stacktrace.