Documentation ¶
Overview ¶
Package log provides leveled structured loggers. It hides the complexity of configuring and using the state-of-the-arts loggers by providing a single interface.
You can either log using an instance logger or the singleton logger. After creating an instance logger, you need to set the singleton logger using the SetSingleton method once. The instance logger can be further used to create more contextualized loggers as the children of the root logger.
Index ¶
- func Close() error
- func Debug(message string, kv ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(message string, kv ...interface{})
- func Errorf(format string, v ...interface{})
- func Info(message string, kv ...interface{})
- func Infof(format string, v ...interface{})
- func SetLevel(level string)
- func SetSingleton(l Logger)
- func Warn(message string, kv ...interface{})
- func Warnf(format string, v ...interface{})
- type Format
- type Level
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(message string, kv ...interface{})
Debug logs a message and a list of key-value pairs in debug level using the singleton logger.
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf formats and logs a message in debug level using the singleton logger. It uses fmt.Sprintf() to log a message.
func Error ¶
func Error(message string, kv ...interface{})
Error logs a message and a list of key-value pairs in error level using the singleton logger.
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf formats and logs a message in error level using the singleton logger. It uses fmt.Sprintf() to log a message.
func Info ¶
func Info(message string, kv ...interface{})
Info logs a message and a list of key-value pairs in info level using the singleton logger.
func Infof ¶
func Infof(format string, v ...interface{})
Infof formats and logs a message in info level using the singleton logger. It uses fmt.Sprintf() to log a message.
func SetLevel ¶
func SetLevel(level string)
SetLevel changes the logging level of the singleton logger.
Types ¶
type Logger ¶
type Logger interface { With(kv ...interface{}) Logger GetLevel() Level SetLevel(level string) Debug(message string, kv ...interface{}) Debugf(format string, args ...interface{}) Info(message string, kv ...interface{}) Infof(format string, args ...interface{}) Warn(message string, kv ...interface{}) Warnf(format string, args ...interface{}) Error(message string, kv ...interface{}) Errorf(format string, args ...interface{}) Close() error }
Logger is a leveled structured logger. It is concurrently safe to be used by multiple goroutines.
func NewNopLogger ¶
func NewNopLogger() Logger
NewNopLogger creates a logger that never logs anything to anywhere! It can be used for testing purposes.