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 GetRequestIDFromContext(ctx context.Context) string
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Infow(template string, kv ...interface{})
- func NewLogger(levelStr string, outputs []string) (*zap.Logger, *zap.AtomicLevel, error)
- func Panic(args ...interface{})
- func SetLevel(level Level)
- func SetLevelStr(levelStr string)
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- func Warnw(template string, kv ...interface{})
- type ContextLogger
- func (l *ContextLogger) Debug(args ...interface{})
- func (l *ContextLogger) Debugf(template string, args ...interface{})
- func (l *ContextLogger) Debugw(msg string, kv ...interface{})
- func (l *ContextLogger) Error(args ...interface{})
- func (l *ContextLogger) Errorf(template string, args ...interface{})
- func (l *ContextLogger) Errorw(msg string, kv ...interface{})
- func (l *ContextLogger) Fatal(args ...interface{})
- func (l *ContextLogger) Fatalf(template string, args ...interface{})
- func (l *ContextLogger) Info(args ...interface{})
- func (l *ContextLogger) Infof(template string, args ...interface{})
- func (l *ContextLogger) Infow(msg string, kv ...interface{})
- func (l *ContextLogger) Panicw(msg string, kv ...interface{})
- func (l *ContextLogger) Warn(args ...interface{})
- func (l *ContextLogger) Warnf(template string, args ...interface{})
- func (l *ContextLogger) Warnw(msg string, kv ...interface{})
- type Level
Constants ¶
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = Level(zap.DebugLevel) // InfoLevel is the default logging priority. InfoLevel = Level(zap.InfoLevel) // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = Level(zap.WarnLevel) // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = Level(zap.ErrorLevel) // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel = Level(zap.DPanicLevel) // PanicLevel logs a message, then panics. PanicLevel = Level(zap.PanicLevel) // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = Level(zap.FatalLevel) )
Duplicated constants from zap for more intuitive usage
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 GetRequestIDFromContext ¶
GetRequestIDFromContext extracts requestID from context
func NewLogger ¶
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 ContextLogger ¶
type ContextLogger struct { Log *zap.SugaredLogger Context context.Context }
ContextLogger is logger that will use context for additional fields
func WithContext ¶
func WithContext(ctx context.Context) *ContextLogger
WithContext creates logger with context
func (*ContextLogger) Debug ¶
func (l *ContextLogger) Debug(args ...interface{})
Debug calls log.Debug
func (*ContextLogger) Debugf ¶
func (l *ContextLogger) Debugf(template string, args ...interface{})
Debugf calls log.Debugf with context fields
func (*ContextLogger) Debugw ¶
func (l *ContextLogger) Debugw(msg string, kv ...interface{})
Debugw is zap debug with context
func (*ContextLogger) Error ¶
func (l *ContextLogger) Error(args ...interface{})
Error calls log.Error with context fields
func (*ContextLogger) Errorf ¶
func (l *ContextLogger) Errorf(template string, args ...interface{})
Errorf calls log.Errorf and stores the error message into the ErrorFile
func (*ContextLogger) Errorw ¶
func (l *ContextLogger) Errorw(msg string, kv ...interface{})
Errorw is zap Errorw with context
func (*ContextLogger) Fatal ¶
func (l *ContextLogger) Fatal(args ...interface{})
Fatal calls log.Fatal with context fields
func (*ContextLogger) Fatalf ¶
func (l *ContextLogger) Fatalf(template string, args ...interface{})
Fatalf calls log.Fatalf with context fields
func (*ContextLogger) Infof ¶
func (l *ContextLogger) Infof(template string, args ...interface{})
Infof calls log.Infof with context fields
func (*ContextLogger) Infow ¶
func (l *ContextLogger) Infow(msg string, kv ...interface{})
Infow is zap Infow with context
func (*ContextLogger) Panicw ¶
func (l *ContextLogger) Panicw(msg string, kv ...interface{})
Panicw is zap Panicw with context
func (*ContextLogger) Warn ¶
func (l *ContextLogger) Warn(args ...interface{})
Warn calls log.Warn with context fields
func (*ContextLogger) Warnf ¶
func (l *ContextLogger) Warnf(template string, args ...interface{})
Warnf calls log.Warnf with context fields
func (*ContextLogger) Warnw ¶
func (l *ContextLogger) Warnw(msg string, kv ...interface{})
Warnw is zap Warnw with context