Documentation
¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Debugw(template string, kv ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Errorw(template string, kv ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Fatalw(template string, kv ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Infow(template string, kv ...interface{})
- func NewLogger(env, levelStr string, outputs []string) (*zap.SugaredLogger, *zap.AtomicLevel, error)
- func SetEnv(env string)
- func SetLevel(level zapcore.Level)
- func SetLevelStr(_levelStr string)
- func Sync()
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- func Warnw(template string, kv ...interface{})
- type DebugLogger
- type ErrorLogger
- type FatalLogger
- type InfoLogger
- type Logger
- type WarnLogger
Constants ¶
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zap.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zap.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zap.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = zap.ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel = zap.DPanicLevel // PanicLevel logs a message, then panics. PanicLevel = zap.PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = zap.FatalLevel )
Duplicated constants from zap for more intuitive usage
const ( // ProductionEnv sets production config (json encoder, etc) ProductionEnv = "production" // DevelopmentEnv adjusts config for development DevelopmentEnv = "development" )
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf calls log.Errorf and stores the error message into the ErrorFile
func NewLogger ¶
func NewLogger(env, levelStr string, outputs []string) (*zap.SugaredLogger, *zap.AtomicLevel, error)
NewLogger creates the logger with defined level. outputs defines the outputs where the logs will be sent. By default, outputs contains "stdout", which prints the logs at the output of the process. To add a log file as output, the path should be added at the outputs array. To avoid printing the logs but storing them on a file, can use []string{"pathtofile.log"}
func SetLevelStr ¶
func SetLevelStr(_levelStr string)
SetLevelStr sets level of default logger from level name Valid values: debug, info, warn, error, dpanic, panic, fatal
Types ¶
type DebugLogger ¶
type DebugLogger interface {
Debug(args ...interface{})
Debugf(template string, args ...interface{})
Debugw(template string, kv ...interface{})
}
DebugLogger Debug* log functions
type ErrorLogger ¶
type ErrorLogger interface {
Error(args ...interface{})
Errorf(template string, args ...interface{})
Errorw(template string, kv ...interface{})
}
ErrorLogger Error* log functions
type FatalLogger ¶
type FatalLogger interface {
Fatal(args ...interface{})
Fatalf(template string, args ...interface{})
Fatalw(template string, kv ...interface{})
}
FatalLogger Fatal* log functions
type InfoLogger ¶
type InfoLogger interface {
Info(args ...interface{})
Infof(template string, args ...interface{})
Infow(template string, kv ...interface{})
}
InfoLogger Info* log functions
type Logger ¶
type Logger interface {
DebugLogger
InfoLogger
WarnLogger
ErrorLogger
FatalLogger
}
Logger is an umbrella interface for all log functions
func WithContext ¶
WithContext creates new logger with wrapped context that would be used to extract request-id value.
type WarnLogger ¶
type WarnLogger interface {
Warn(args ...interface{})
Warnf(template string, args ...interface{})
Warnw(template string, kv ...interface{})
}
WarnLogger Warn* log functions