Documentation
¶
Index ¶
Constants ¶
const ( // RootLoggerName is the name of the root logger RootLoggerName = Name("") // RootLoggerAlias is an alias of the root logger RootLoggerAlias = "all" )
const ( DebugLevel = zap.DebugLevel InfoLevel = zap.InfoLevel WarnLevel = zap.WarnLevel ErrorLevel = zap.ErrorLevel PanicLevel = zap.PanicLevel FatalLevel = zap.FatalLevel )
===========================================================================
Variables ¶
This section is empty.
Functions ¶
func AddLogger ¶
AddLogger returns an HTTP middleware that injects the given logger to the request context
func CatchPanic ¶
func CatchPanic(f func()) (err error)
CatchPanic calls a function, returning any panic as error
func RecoverError ¶
func RecoverError() error
RecoverError recovers from a panic and returns an error in that case
Types ¶
type Config ¶
type Config struct {
Level LoggerLevels
Quiet bool
Debug bool
}
Config holds the logging configuration and is used the build the Factory.
type Factory ¶
type Factory struct {
Config
// contains filtered or unexported fields
}
Factory is used to build Loggers.
type Logger ¶
type Logger interface {
DPanic(...interface{})
DPanicf(string, ...interface{})
DPanicw(string, ...interface{})
Debug(...interface{})
Debugf(string, ...interface{})
Debugw(string, ...interface{})
Error(...interface{})
Errorf(string, ...interface{})
Errorw(string, ...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalw(string, ...interface{})
Info(...interface{})
Infof(string, ...interface{})
Infow(string, ...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicw(string, ...interface{})
Warn(...interface{})
Warnf(string, ...interface{})
Warnw(string, ...interface{})
Named(string) Logger
With(...interface{}) Logger
Sync() error
Writer() io.WriteCloser
StdLoggerAt(zapcore.Level) (*log.Logger, error)
}
Logger is a logger object
func FromContext ¶
FromContext gets the Logger from the Context
func MustFromContext ¶
FromContext gets the Logger from the Context
func NewTesting ¶
NewTesting creates a logger that forwards everything to the testing log.
type LoggerLevels ¶
LoggerLevels is a map of Levels for Logger Names
func (LoggerLevels) Resolve ¶
func (l LoggerLevels) Resolve(name Name) zapcore.Level
Resolve returns the Level to use for the Named Logger.
func (LoggerLevels) Set ¶
func (l LoggerLevels) Set(value string) (err error)
Set implements flags.Value. It parses a comma-separater strings of name:level couples.