Documentation
¶
Overview ¶
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Package internal of logger unifies different types of loggers into interfaces Logger. For example it allows to upgrade simple fmt.Printf to be a fully functional Logger. Therefore multiple wrappers are implemented here to provide different functions which could be missing in some loggers.
Index ¶
- Constants
- func MinimalLoggerLogf(l MinimalLogger, level Level, format string, args ...interface{})
- type DummyLogger
- type ExtendWrapper
- func (l ExtendWrapper) Debugf(format string, args ...interface{})
- func (l ExtendWrapper) Errorf(format string, args ...interface{})
- func (l ExtendWrapper) Fatalf(format string, args ...interface{})
- func (l ExtendWrapper) Infof(format string, args ...interface{})
- func (l ExtendWrapper) Level() Level
- func (l ExtendWrapper) OriginalLogger() interface{}
- func (l ExtendWrapper) Panicf(format string, args ...interface{})
- func (l ExtendWrapper) Warnf(format string, args ...interface{})
- func (l ExtendWrapper) WithField(key string, value interface{}) Logger
- func (l ExtendWrapper) WithFields(fields Fields) Logger
- func (l ExtendWrapper) WithLevel(level Level) Logger
- type Fields
- type Level
- type Logger
- type LoggerCompact
- type LoggerExtensions
- type MinimalLogger
- type MinimalLoggerCompact
- type UncompactLoggerCompact
- func (l UncompactLoggerCompact) Debugf(format string, args ...interface{})
- func (l UncompactLoggerCompact) Errorf(format string, args ...interface{})
- func (l UncompactLoggerCompact) Fatalf(format string, args ...interface{})
- func (l UncompactLoggerCompact) Infof(format string, args ...interface{})
- func (l UncompactLoggerCompact) OriginalLogger() interface{}
- func (l UncompactLoggerCompact) Panicf(format string, args ...interface{})
- func (l UncompactLoggerCompact) Warnf(format string, args ...interface{})
- type UncompactMinimalLoggerCompact
- func (l UncompactMinimalLoggerCompact) Debugf(format string, args ...interface{})
- func (l UncompactMinimalLoggerCompact) Errorf(format string, args ...interface{})
- func (l UncompactMinimalLoggerCompact) Fatalf(format string, args ...interface{})
- func (l UncompactMinimalLoggerCompact) Infof(format string, args ...interface{})
- func (l UncompactMinimalLoggerCompact) OriginalLogger() interface{}
- func (l UncompactMinimalLoggerCompact) Panicf(format string, args ...interface{})
- func (l UncompactMinimalLoggerCompact) Warnf(format string, args ...interface{})
- type WithFields
- type WithLevels
Constants ¶
const ( // LevelUndefined is the erroneous value of log-level which corresponds // to zero-value. LevelUndefined = Level(iota) // LevelFatal will report about Fatalf-s only. LevelFatal // LevelPanic will report about Panicf-s and Fatalf-s only. LevelPanic // LevelError will report about Errorf-s, Panicf-s, ... LevelError // LevelWarning will report about Warningf-s, Errorf-s, ... LevelWarning // LevelInfo will report about Infof-s, Warningf-s, ... LevelInfo // LevelDebug will report about Debugf-s, Infof-s, ... LevelDebug )
Variables ¶
This section is empty.
Functions ¶
func MinimalLoggerLogf ¶
func MinimalLoggerLogf( l MinimalLogger, level Level, format string, args ...interface{}, )
MinimalLoggerLogf is an implementation of method Logf (of interface MinimalLoggerCompact) based on MinimalLogger.
This function is implemented here to deduplicate code among logadapter-s.
Types ¶
type DummyLogger ¶
type DummyLogger struct{}
DummyLogger is just a logger which does nothing. To do not duplicate anything we just implement MinimalLoggerCompact and the rest methods could be added using wrappers (see logger.ConvertLogger).
func (DummyLogger) Logf ¶
func (DummyLogger) Logf(_ Level, _ string, _ ...interface{})
Logf implements MinimalLoggerCompact.
type ExtendWrapper ¶
type ExtendWrapper struct { MinimalLogger Prefix string CurLevel Level }
ExtendWrapper implements Logger based on MinimalLogger.
Thus if you have only a MinimalLogger, you can extend it to a Logger using this wrapper.
It is called ExtendWrapper because it actually implements only LoggerExtensions.
func (ExtendWrapper) Debugf ¶
func (l ExtendWrapper) Debugf(format string, args ...interface{})
Debugf implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Debugf but also checks if the logging level is satisfied.
func (ExtendWrapper) Errorf ¶
func (l ExtendWrapper) Errorf(format string, args ...interface{})
Errorf implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Errorf but also checks if the logging level is satisfied.
func (ExtendWrapper) Fatalf ¶
func (l ExtendWrapper) Fatalf(format string, args ...interface{})
Fatalf implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Fatalf but also checks if the logging level is satisfied.
func (ExtendWrapper) Infof ¶
func (l ExtendWrapper) Infof(format string, args ...interface{})
Infof implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Infof but also checks if the logging level is satisfied.
func (ExtendWrapper) Level ¶
func (l ExtendWrapper) Level() Level
Level implements LoggerExtensions.
func (ExtendWrapper) OriginalLogger ¶
func (l ExtendWrapper) OriginalLogger() interface{}
OriginalLogger implements LoggerExtensions.
func (ExtendWrapper) Panicf ¶
func (l ExtendWrapper) Panicf(format string, args ...interface{})
Panicf implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Panicf but also checks if the logging level is satisfied.
func (ExtendWrapper) Warnf ¶
func (l ExtendWrapper) Warnf(format string, args ...interface{})
Warnf implements MinimalLogger.
It calls the backend ExtendWrapper.MinimalLogger.Warnf but also checks if the logging level is satisfied.
func (ExtendWrapper) WithField ¶
func (l ExtendWrapper) WithField(key string, value interface{}) Logger
WithField implements LoggerExtensions.
func (ExtendWrapper) WithFields ¶
func (l ExtendWrapper) WithFields(fields Fields) Logger
WithFields implements LoggerExtensions.
func (ExtendWrapper) WithLevel ¶
func (l ExtendWrapper) WithLevel(level Level) Logger
WithLevel implements LoggerExtensions.
type Level ¶
type Level int
Level is used to define severity of messages to be reported.
func ParseLogLevel ¶
ParseLogLevel parses incoming string into a Level and returns LevelUndefined with an error if an unknown logging level was passed.
func (*Level) Set ¶
Set updates the logging level values based on the passed string value. This method just implements flag.Value and pflag.Value.
type Logger ¶
type Logger interface { MinimalLogger LoggerExtensions }
Logger is the interface of a logger provided by an extended context.
This is the complete logger with all the required methods/features.
func WrapMinimalLogger ¶
func WrapMinimalLogger(logger MinimalLogger) Logger
WrapMinimalLogger wraps a MinimalLogger to provide a Logger.
func WrapMinimalLoggerCompact ¶
func WrapMinimalLoggerCompact(logger MinimalLoggerCompact) Logger
WrapMinimalLoggerCompact wraps a MinimalLoggerCompact to provide a Logger.
func WrapPrintf ¶
WrapPrintf wraps a Printf-like function to provide a Logger.
type LoggerCompact ¶
type LoggerCompact interface { MinimalLoggerCompact LoggerExtensions }
LoggerCompact is a kind of logger with one method Logf(level, ...) instead of separate methods Debugf(...), Infof(...), Warnf(...) and so on.
type LoggerExtensions ¶
type LoggerExtensions interface { // OriginalLogger returns the original logger without wrappers added // by this package. OriginalLogger() interface{} WithLevels WithFields }
LoggerExtensions includes all the features required for a Logger over MinimalLogger.
type MinimalLogger ¶
type MinimalLogger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) }
MinimalLogger is a simple logger, for example logrus.Entry or zap.SugaredLogger could be candidates of an implementation of this interfaces.
Note: logrus.Entry and zap.SugaredLogger supports structured logging and they have With* methods, but the API is different, so we do not require that methods here. We add support of builtin structured logging and logging levels through logadapter-s, see for example logadapter/logrus.Adapter.Convert.
type MinimalLoggerCompact ¶
type UncompactLoggerCompact ¶
type UncompactLoggerCompact struct {
LoggerCompact
}
UncompactLoggerCompact converts LoggerCompact to Logger.
func (UncompactLoggerCompact) Debugf ¶
func (l UncompactLoggerCompact) Debugf(format string, args ...interface{})
Debugf implements MinimalLogger.
func (UncompactLoggerCompact) Errorf ¶
func (l UncompactLoggerCompact) Errorf(format string, args ...interface{})
Errorf implements MinimalLogger.
func (UncompactLoggerCompact) Fatalf ¶
func (l UncompactLoggerCompact) Fatalf(format string, args ...interface{})
Fatalf implements MinimalLogger.
func (UncompactLoggerCompact) Infof ¶
func (l UncompactLoggerCompact) Infof(format string, args ...interface{})
Infof implements MinimalLogger.
func (UncompactLoggerCompact) OriginalLogger ¶
func (l UncompactLoggerCompact) OriginalLogger() interface{}
OriginalLogger implements LoggerExtensions.
func (UncompactLoggerCompact) Panicf ¶
func (l UncompactLoggerCompact) Panicf(format string, args ...interface{})
Panicf implements MinimalLogger.
func (UncompactLoggerCompact) Warnf ¶
func (l UncompactLoggerCompact) Warnf(format string, args ...interface{})
Warnf implements MinimalLogger.
type UncompactMinimalLoggerCompact ¶
type UncompactMinimalLoggerCompact struct {
MinimalLoggerCompact
}
UncompactMinimalLoggerCompact converts MinimalLoggerCompact to MinimalLogger.
func (UncompactMinimalLoggerCompact) Debugf ¶
func (l UncompactMinimalLoggerCompact) Debugf(format string, args ...interface{})
Debugf implements MinimalLogger.
func (UncompactMinimalLoggerCompact) Errorf ¶
func (l UncompactMinimalLoggerCompact) Errorf(format string, args ...interface{})
Errorf implements MinimalLogger.
func (UncompactMinimalLoggerCompact) Fatalf ¶
func (l UncompactMinimalLoggerCompact) Fatalf(format string, args ...interface{})
Fatalf implements MinimalLogger.
func (UncompactMinimalLoggerCompact) Infof ¶
func (l UncompactMinimalLoggerCompact) Infof(format string, args ...interface{})
Infof implements MinimalLogger.
func (UncompactMinimalLoggerCompact) OriginalLogger ¶
func (l UncompactMinimalLoggerCompact) OriginalLogger() interface{}
OriginalLogger implements LoggerExtensions.
func (UncompactMinimalLoggerCompact) Panicf ¶
func (l UncompactMinimalLoggerCompact) Panicf(format string, args ...interface{})
Panicf implements MinimalLogger.
func (UncompactMinimalLoggerCompact) Warnf ¶
func (l UncompactMinimalLoggerCompact) Warnf(format string, args ...interface{})
Warnf implements MinimalLogger.
type WithFields ¶
type WithFields interface { // WithField returns a logger with added field (used for structured logging). WithField(key string, value interface{}) Logger // WithFields returns a logger with added fields (used for structured logging). WithFields(fields Fields) Logger }
WithFields requires methods of a logger with support of structured logging.
type WithLevels ¶
type WithLevels interface { // Level returns the current logging level. Level() Level // WithLevel returns a logger with logger level set to the passed argument. WithLevel(Level) Logger }
WithLevels requires methods of a logger with support of logging levels.