Documentation
¶
Overview ¶
Package log can be used for structured logging. It supports a singleton (global) logger as well as instantiating new loggers.
Index ¶
- func ContextWithLogger(ctx context.Context, logger *Logger) context.Context
- func Debug(message string)
- func DebugKV(kv ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(message string)
- func ErrorKV(kv ...interface{})
- func Errorf(format string, v ...interface{})
- func Info(message string)
- func InfoKV(kv ...interface{})
- func Infof(format string, v ...interface{})
- func SetLevel(level string)
- func SetOptions(opts Options)
- func Warn(message string)
- func WarnKV(kv ...interface{})
- func Warnf(format string, v ...interface{})
- type Format
- type Level
- type Logger
- func (l *Logger) Debug(message string)
- func (l *Logger) DebugKV(kv ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(message string)
- func (l *Logger) ErrorKV(kv ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Info(message string)
- func (l *Logger) InfoKV(kv ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) SetLevel(level string)
- func (l *Logger) SetOptions(opts Options)
- func (l *Logger) Warn(message string)
- func (l *Logger) WarnKV(kv ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) With(kv ...interface{}) *Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithLogger ¶ added in v0.2.3
ContextWithLogger returns a new context that holds a reference to the logger.
func DebugKV ¶ added in v0.4.0
func DebugKV(kv ...interface{})
DebugKV logs key-value pairs in debug level using singleton logger.
func Debugf ¶ added in v0.4.0
func Debugf(format string, v ...interface{})
Debugf logs a message in debug level using singleton logger. It uses fmt.Sprintf() to log a message.
func ErrorKV ¶ added in v0.4.0
func ErrorKV(kv ...interface{})
ErrorKV logs key-value pairs in error level using singleton logger.
func Errorf ¶ added in v0.4.0
func Errorf(format string, v ...interface{})
Errorf logs a message in error level using singleton logger. It uses fmt.Sprintf() to log a message.
func InfoKV ¶ added in v0.4.0
func InfoKV(kv ...interface{})
InfoKV logs key-value pairs in info level using singleton logger.
func Infof ¶ added in v0.4.0
func Infof(format string, v ...interface{})
Infof logs a message in info level using singleton logger. It uses fmt.Sprintf() to log a message.
func SetLevel ¶ added in v0.3.3
func SetLevel(level string)
SetLevel changes the level of singleton logger.
func SetOptions ¶
func SetOptions(opts Options)
SetOptions set optional options for singleton logger.
Types ¶
type Logger ¶
type Logger struct { Level Level // contains filtered or unexported fields }
Logger wraps a go-kit Logger.
func LoggerFromContext ¶ added in v0.2.3
LoggerFromContext returns a logger set on a context. If no logger found on the context, the singleton logger will be returned.
func NewVoidLogger ¶ added in v0.2.0
func NewVoidLogger() *Logger
NewVoidLogger creates a void logger for testing purposes.
func (*Logger) DebugKV ¶ added in v0.4.0
func (l *Logger) DebugKV(kv ...interface{})
DebugKV logs key-value pairs in debug level.
func (*Logger) Debugf ¶ added in v0.4.0
Debugf logs a message in debug level. It uses fmt.Sprintf() to log a message.
func (*Logger) ErrorKV ¶ added in v0.4.0
func (l *Logger) ErrorKV(kv ...interface{})
ErrorKV logs key-value pairs in error level.
func (*Logger) Errorf ¶ added in v0.4.0
Errorf logs a message in error level. It uses fmt.Sprintf() to log a message.
func (*Logger) InfoKV ¶ added in v0.4.0
func (l *Logger) InfoKV(kv ...interface{})
InfoKV logs key-value pairs in info level.
func (*Logger) Infof ¶ added in v0.4.0
Infof logs a message in info level. It uses fmt.Sprintf() to log a message.
func (*Logger) SetOptions ¶ added in v0.2.0
SetOptions resets a logger with new options.
func (*Logger) WarnKV ¶ added in v0.4.0
func (l *Logger) WarnKV(kv ...interface{})
WarnKV logs key-value pairs in warn level.