Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func ErrorField(err error) zap.Field
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func HTTPRequestDump(key string, req *http.Request) zap.Field
- func HTTPRequestDumpBody(key string, req *http.Request) zap.Field
- func HTTPResponseDump(key string, req *http.Response) zap.Field
- func HTTPResponseDumpBody(key string, req *http.Response) zap.Field
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func SetLevel(level Level)
- func SetLogger(logger Logger)
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- type BasicEntry
- type Configuration
- type Entry
- type Hook
- type Level
- type Logger
- type LogrusHook
- type LogrusLogger
- func (std *LogrusLogger) AddHook(hook Hook)
- func (std *LogrusLogger) Debug(args ...interface{})
- func (std *LogrusLogger) Debugf(format string, args ...interface{})
- func (std *LogrusLogger) Debugln(args ...interface{})
- func (std *LogrusLogger) Error(args ...interface{})
- func (std *LogrusLogger) Errorf(format string, args ...interface{})
- func (std *LogrusLogger) Errorln(args ...interface{})
- func (std *LogrusLogger) Fatal(args ...interface{})
- func (std *LogrusLogger) Fatalf(format string, args ...interface{})
- func (std *LogrusLogger) Fatalln(args ...interface{})
- func (std *LogrusLogger) GetLevel() Level
- func (std *LogrusLogger) Info(args ...interface{})
- func (std *LogrusLogger) Infof(format string, args ...interface{})
- func (std *LogrusLogger) Infoln(args ...interface{})
- func (std *LogrusLogger) Log(level Level, args ...interface{})
- func (std *LogrusLogger) Logf(level Level, format string, args ...interface{})
- func (std *LogrusLogger) Logln(level Level, args ...interface{})
- func (std *LogrusLogger) Panic(args ...interface{})
- func (std *LogrusLogger) Panicf(format string, args ...interface{})
- func (std *LogrusLogger) Panicln(args ...interface{})
- func (std *LogrusLogger) Print(args ...interface{})
- func (std *LogrusLogger) Printf(format string, args ...interface{})
- func (std *LogrusLogger) Println(args ...interface{})
- func (std *LogrusLogger) SetLevel(level Level)
- func (std *LogrusLogger) SetOutput(out io.Writer)
- func (std *LogrusLogger) Warn(args ...interface{})
- func (std *LogrusLogger) Warnf(format string, args ...interface{})
- func (std *LogrusLogger) Warning(args ...interface{})
- func (std *LogrusLogger) Warningf(format string, args ...interface{})
- func (std *LogrusLogger) Warningln(args ...interface{})
- func (std *LogrusLogger) Warnln(args ...interface{})
- type StructuredLogger
- type StructuredNopLogger
- type ZapLogger
- type ZapSyslogCore
Constants ¶
const ( // Logger encoding types. EncodingJSON = "json" EncodingPlain = "plain" // LogLevelPanic level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... LogLevelPanic = "PANIC" // LogLevelFatal level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. LogLevelFatal = "FATAL" // LogLevelError level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. LogLevelError = "ERROR" // LogLevelWarn level. Non-critical entries that deserve eyes. LogLevelWarn = "WARN" // LogInfoLevel level. General operational entries about what's going on inside the // application. LogLevelInfo = "INFO" // LogLevelDebug level. Usually only enabled when debugging. Very verbose logging. LogLevelDebug = "DEBUG" )
Variables ¶
var AllLevels = []Level{ PanicLevel, FatalLevel, ErrorLevel, WarnLevel, InfoLevel, DebugLevel, }
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func Debugln ¶
func Debugln(args ...interface{})
Debugln logs a message at level Debug on the standard logger.
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func ErrorField ¶
ErrorField creates a zap.Field for the corresponding error.
By default it creates zapcore.ErrorType field the same way zap.Error() does it.
If the error implements the Location interface from github.com/sumup-oss/go-pkgs/errors, it will add a `trace` field in the log with the error stack trace.
The Location interface looks like this:
interface { Location() (function, file string, line int) }
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs a message at level Error on the standard logger.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs a message at level Fatal on the standard logger.
func HTTPRequestDump ¶
HTTPRequestDump creates a zap.Field that can dump http request lazily.
It is typically used with logger Debug calls. NOTE: The http request body is not dumped. For that use HTTRequestDumpBody.
func HTTPRequestDumpBody ¶
HTTPRequestDumpBody creates a zap.Field that can dump http request along with its body lazily.
It is typically used with logger Debug calls. NOTE: If you want to dump the request path and headers only, use HTTPRequestDump.
func HTTPResponseDump ¶
HTTPResponseDump creates a zap.Field that can dump http response lazily.
It is typically used with logger Debug calls. NOTE: The http response body is not dumped. For that use HTTResponseDumpBody.
func HTTPResponseDumpBody ¶
HTTPResponseDumpBody creates a zap.Field that can dump http request along with its body lazily.
It is typically used with logger Debug calls. NOTE: If you want to dump the response path and headers only, use HTTPResponseDump.
func Info ¶
func Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs a message at level Info on the standard logger.
func Panic ¶
func Panic(args ...interface{})
Panic logs a message at level Panic on the standard logger.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the standard logger.
func Panicln ¶
func Panicln(args ...interface{})
Panicln logs a message at level Panic on the standard logger.
func Print ¶
func Print(args ...interface{})
Print logs a message at level Info on the standard logger.
func Printf ¶
func Printf(format string, args ...interface{})
Printf logs a message at level Info on the standard logger.
func Println ¶
func Println(args ...interface{})
Println logs a message at level Info on the standard logger.
func Warn ¶
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard logger.
func Warning ¶
func Warning(args ...interface{})
Warning logs a message at level Warn on the standard logger.
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs a message at level Warn on the standard logger.
Types ¶
type BasicEntry ¶
type BasicEntry struct { Time time.Time Level Level Message string Buffer *bytes.Buffer Fields map[string]interface{} }
func (*BasicEntry) GetBuffer ¶
func (entry *BasicEntry) GetBuffer() *bytes.Buffer
func (*BasicEntry) GetFields ¶
func (entry *BasicEntry) GetFields() map[string]interface{}
func (*BasicEntry) GetLevel ¶
func (entry *BasicEntry) GetLevel() Level
func (*BasicEntry) GetMessage ¶
func (entry *BasicEntry) GetMessage() string
func (*BasicEntry) GetTime ¶
func (entry *BasicEntry) GetTime() time.Time
type Configuration ¶
type Configuration struct { Level string Encoding string StdoutEnabled bool SyslogEnabled bool // SyslogFacility is one of `KERN,USER,MAIL,DAEMON,AUTH,SYSLOG,LPR,NEWS,UUCP,CRON,AUTHPRIV,FTP,LOCAL0, // LOCAL1,LOCAL2,LOCAL3,LOCAL4,LOCAL5,LOCAL6,LOCAL7` SyslogFacility string // SyslogTag is tag for all messages produced SyslogTag string // Fields is an optional slice of fields which will be logged on each log invokation Fields []zapcore.Field }
type Level ¶
type Level uint32
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel )
type Logger ¶
type Logger interface { Debug(args ...interface{}) Print(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Panic(args ...interface{}) Fatal(args ...interface{}) Debugf(format string, args ...interface{}) Printf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Debugln(args ...interface{}) Println(args ...interface{}) Infoln(args ...interface{}) Warnln(args ...interface{}) Warningln(args ...interface{}) Errorln(args ...interface{}) Panicln(args ...interface{}) Fatalln(args ...interface{}) Logf(level Level, format string, args ...interface{}) Log(level Level, args ...interface{}) Logln(level Level, args ...interface{}) SetLevel(level Level) GetLevel() Level }
type LogrusHook ¶
type LogrusHook struct { Hook Hook TriggerLevels []Level // contains filtered or unexported fields }
func (*LogrusHook) Levels ¶
func (hook *LogrusHook) Levels() []logrus.Level
type LogrusLogger ¶
type LogrusLogger struct {
// contains filtered or unexported fields
}
func NewLogrusLogger ¶
func NewLogrusLogger() *LogrusLogger
func (*LogrusLogger) AddHook ¶
func (std *LogrusLogger) AddHook(hook Hook)
AddHook adds a hook to the standard logger hooks.
func (*LogrusLogger) Debug ¶
func (std *LogrusLogger) Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func (*LogrusLogger) Debugf ¶
func (std *LogrusLogger) Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func (*LogrusLogger) Debugln ¶
func (std *LogrusLogger) Debugln(args ...interface{})
Debugln logs a message at level Debug on the standard logger.
func (*LogrusLogger) Error ¶
func (std *LogrusLogger) Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func (*LogrusLogger) Errorf ¶
func (std *LogrusLogger) Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func (*LogrusLogger) Errorln ¶
func (std *LogrusLogger) Errorln(args ...interface{})
Errorln logs a message at level Error on the standard logger.
func (*LogrusLogger) Fatal ¶
func (std *LogrusLogger) Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger.
func (*LogrusLogger) Fatalf ¶
func (std *LogrusLogger) Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger.
func (*LogrusLogger) Fatalln ¶
func (std *LogrusLogger) Fatalln(args ...interface{})
Fatalln logs a message at level Fatal on the standard logger.
func (*LogrusLogger) GetLevel ¶
func (std *LogrusLogger) GetLevel() Level
GetLevel returns the standard logger level.
func (*LogrusLogger) Info ¶
func (std *LogrusLogger) Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func (*LogrusLogger) Infof ¶
func (std *LogrusLogger) Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func (*LogrusLogger) Infoln ¶
func (std *LogrusLogger) Infoln(args ...interface{})
Infoln logs a message at level Info on the standard logger.
func (*LogrusLogger) Log ¶
func (std *LogrusLogger) Log(level Level, args ...interface{})
Log logs a message at specified level on the standard logger.
func (*LogrusLogger) Logf ¶
func (std *LogrusLogger) Logf(level Level, format string, args ...interface{})
Logf logs a message at specified level on the standard logger.
func (*LogrusLogger) Logln ¶
func (std *LogrusLogger) Logln(level Level, args ...interface{})
Logln logs a message at specified level on the standard logger.
func (*LogrusLogger) Panic ¶
func (std *LogrusLogger) Panic(args ...interface{})
Panic logs a message at level Panic on the standard logger.
func (*LogrusLogger) Panicf ¶
func (std *LogrusLogger) Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the standard logger.
func (*LogrusLogger) Panicln ¶
func (std *LogrusLogger) Panicln(args ...interface{})
Panicln logs a message at level Panic on the standard logger.
func (*LogrusLogger) Print ¶
func (std *LogrusLogger) Print(args ...interface{})
Print logs a message at level Info on the standard logger.
func (*LogrusLogger) Printf ¶
func (std *LogrusLogger) Printf(format string, args ...interface{})
Printf logs a message at level Info on the standard logger.
func (*LogrusLogger) Println ¶
func (std *LogrusLogger) Println(args ...interface{})
Println logs a message at level Info on the standard logger.
func (*LogrusLogger) SetLevel ¶
func (std *LogrusLogger) SetLevel(level Level)
SetLevel sets the standard logger level.
func (*LogrusLogger) SetOutput ¶
func (std *LogrusLogger) SetOutput(out io.Writer)
SetOutput sets the standard logger output.
func (*LogrusLogger) Warn ¶
func (std *LogrusLogger) Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
func (*LogrusLogger) Warnf ¶
func (std *LogrusLogger) Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard logger.
func (*LogrusLogger) Warning ¶
func (std *LogrusLogger) Warning(args ...interface{})
Warning logs a message at level Warn on the standard logger.
func (*LogrusLogger) Warningf ¶
func (std *LogrusLogger) Warningf(format string, args ...interface{})
Warningf logs a message at level Warn on the standard logger.
func (*LogrusLogger) Warningln ¶
func (std *LogrusLogger) Warningln(args ...interface{})
Warningln logs a message at level Warn on the standard logger.
func (*LogrusLogger) Warnln ¶
func (std *LogrusLogger) Warnln(args ...interface{})
Warnln logs a message at level Warn on the standard logger.
type StructuredLogger ¶
type StructuredLogger interface { Panic(msg string, fields ...zap.Field) Fatal(msg string, fields ...zap.Field) Error(msg string, fields ...zap.Field) Info(msg string, fields ...zap.Field) Warn(msg string, fields ...zap.Field) Debug(msg string, fields ...zap.Field) // With creates a child logger and adds structured context to it. Fields added // to the child don't affect the parent, and vice versa. With(fields ...zap.Field) StructuredLogger GetLevel() zapcore.Level Sync() error }
type StructuredNopLogger ¶
StructuredNopLogger is no-op StructuredLogger.
func NewStructuredNopLogger ¶
func NewStructuredNopLogger(level string) *StructuredNopLogger
NewStructuredNopLogger returns a no-op StructuredLogger.
Note that if the passed level is not recognized it will default to INFO.
func (*StructuredNopLogger) GetLevel ¶
func (z *StructuredNopLogger) GetLevel() zapcore.Level
func (*StructuredNopLogger) With ¶
func (z *StructuredNopLogger) With(fields ...zap.Field) StructuredLogger
With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.
type ZapLogger ¶
func NewZapLogger ¶
func NewZapLogger(config Configuration) (*ZapLogger, error)
type ZapSyslogCore ¶
type ZapSyslogCore struct { zapcore.LevelEnabler // contains filtered or unexported fields }
func NewZapSyslogCore ¶
func NewZapSyslogCore(enab zapcore.LevelEnabler, encoder zapcore.Encoder, writer gsyslog.Syslogger) *ZapSyslogCore
func (*ZapSyslogCore) Check ¶
func (core *ZapSyslogCore) Check(entry zapcore.Entry, checked *zapcore.CheckedEntry) *zapcore.CheckedEntry
NOTE: We pass `entry` by value to satisfy the interface requirements nolint:gocritic
func (*ZapSyslogCore) Sync ¶
func (core *ZapSyslogCore) Sync() error