Documentation ¶
Index ¶
- type BasicLogger
- func (l *BasicLogger) Debug(args ...interface{})
- func (l *BasicLogger) Debugf(format string, args ...interface{})
- func (l *BasicLogger) Error(args ...interface{})
- func (l *BasicLogger) Errorf(format string, args ...interface{})
- func (l *BasicLogger) Fatal(args ...interface{})
- func (l *BasicLogger) Fatalf(format string, args ...interface{})
- func (l *BasicLogger) Info(args ...interface{})
- func (l *BasicLogger) Infof(format string, args ...interface{})
- func (l *BasicLogger) Panic(args ...interface{})
- func (l *BasicLogger) Panicf(format string, args ...interface{})
- func (l *BasicLogger) Print(args ...interface{})
- func (l *BasicLogger) Printf(format string, args ...interface{})
- func (l *BasicLogger) SetLevel(level Level)
- func (l *BasicLogger) Warning(args ...interface{})
- func (l *BasicLogger) Warningf(format string, args ...interface{})
- type ExtendedLeveledLogger
- type Level
- type LeveledLogger
- type LoggerWrapper
- func (c *LoggerWrapper) Debug(args ...interface{})
- func (c *LoggerWrapper) Debugf(format string, args ...interface{})
- func (c *LoggerWrapper) Debugln(args ...interface{})
- func (c *LoggerWrapper) Error(args ...interface{})
- func (c *LoggerWrapper) Errorf(format string, args ...interface{})
- func (c *LoggerWrapper) Errorln(args ...interface{})
- func (c *LoggerWrapper) Fatal(args ...interface{})
- func (c *LoggerWrapper) Fatalf(format string, args ...interface{})
- func (c *LoggerWrapper) Fatalln(args ...interface{})
- func (c *LoggerWrapper) Info(args ...interface{})
- func (c *LoggerWrapper) Infof(format string, args ...interface{})
- func (c *LoggerWrapper) Infoln(args ...interface{})
- func (c *LoggerWrapper) Panic(args ...interface{})
- func (c *LoggerWrapper) Panicf(format string, args ...interface{})
- func (c *LoggerWrapper) Panicln(args ...interface{})
- func (c *LoggerWrapper) Print(args ...interface{})
- func (c *LoggerWrapper) Printf(format string, args ...interface{})
- func (c *LoggerWrapper) Println(args ...interface{})
- func (c *LoggerWrapper) Warning(args ...interface{})
- func (c *LoggerWrapper) Warningf(format string, args ...interface{})
- func (c *LoggerWrapper) Warningln(args ...interface{})
- type Message
- type ShortLeveledLogger
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicLogger ¶
type BasicLogger struct {
// contains filtered or unexported fields
}
BasicLogger is simple leveled logger that implements LeveledLogger interface. It uses 5 basic log levels:
# DEBUG # INFO # WARNING # ERROR # CRITICAL
By default DEBUG level is used. It may be reset using SetLevel() method. It allows to filter the logs by given level. I.e. Having BasicLogger with level Set to WARNING, then there would be no DEBUG and INFO logs (the hierarchy goes up only).
func NewBasicLogger ¶
func NewBasicLogger(out io.Writer, prefix string, flags int) *BasicLogger
NewBasicLogger creates new BasicLogger that shares common sequence id. By default it uses DEBUG level. It can be changed later using SetLevel() method. BasicLogger uses standard library *log.Logger for logging purpose. The arguments used in this function are described in log.New() method.
func (*BasicLogger) Debug ¶
func (l *BasicLogger) Debug(args ...interface{})
Logs a message with DEBUG level.
func (*BasicLogger) Debugf ¶
func (l *BasicLogger) Debugf(format string, args ...interface{})
Logs a formatted message with DEBUG level
func (*BasicLogger) Error ¶
func (l *BasicLogger) Error(args ...interface{})
Logs a message with ERROR level. Arguments are handled in a log.Print manner.
func (*BasicLogger) Errorf ¶
func (l *BasicLogger) Errorf(format string, args ...interface{})
Logs a formatted message with ERROR level. Arguments are handled in a log.Printf manner.
func (*BasicLogger) Fatal ¶
func (l *BasicLogger) Fatal(args ...interface{})
Logs a message with CRITICAL level. Afterwards the function execute os.Exit(1). Arguments are handled in a log.Print manner.
func (*BasicLogger) Fatalf ¶
func (l *BasicLogger) Fatalf(format string, args ...interface{})
Logs a formatted message with CRITICAL level. Afterwards the function execute os.Exit(1). Arguments are handled in a log.Printf manner.
func (*BasicLogger) Info ¶
func (l *BasicLogger) Info(args ...interface{})
Logs a message with INFO level
func (*BasicLogger) Infof ¶
func (l *BasicLogger) Infof(format string, args ...interface{})
Logs a formatted message with INFO level.
func (*BasicLogger) Panic ¶
func (l *BasicLogger) Panic(args ...interface{})
Logs a message with CRITICAL level. Afterwards the function panics with given message. Arguments are handled in a log.Print manner.
func (*BasicLogger) Panicf ¶
func (l *BasicLogger) Panicf(format string, args ...interface{})
Logs a formatted message with CRITICAL level. Afterwards the function panics with given formatted message. Arguments are handled in a log.Printf manner.
func (*BasicLogger) Print ¶
func (l *BasicLogger) Print(args ...interface{})
Logs a message. Arguments are handled in a log.Print manner.
func (*BasicLogger) Printf ¶
func (l *BasicLogger) Printf(format string, args ...interface{})
Logs a formatted message. Arguments are handled in a log.Printf manner.
func (*BasicLogger) SetLevel ¶
func (l *BasicLogger) SetLevel(level Level)
SetLevel sets the level of logging for given Logger.
func (*BasicLogger) Warning ¶
func (l *BasicLogger) Warning(args ...interface{})
Logs a message with WARNING level. Arguments are handled in a log.Print manner.
func (*BasicLogger) Warningf ¶
func (l *BasicLogger) Warningf(format string, args ...interface{})
Logs a formatted message with WARNING level. Arguments are handled in a log.Printf manner.
type ExtendedLeveledLogger ¶
type ExtendedLeveledLogger interface { Print(args ...interface{}) Printf(format string, args ...interface{}) Println(args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Warningln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) }
ExtendedLogger adds distinction between Leveled methods that starts new or not i.e.: 'Debugln' and 'Debug'. It also adds all Print's methods.
type Level ¶
type Level int
*
Levels ¶
Level defines a logging level used in BasicLogger
Following levels are supported in BasicLogger
type LeveledLogger ¶
type LeveledLogger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) }
LeveledLogger is a logger that uses basic logging leveles
type LoggerWrapper ¶
type LoggerWrapper struct {
// contains filtered or unexported fields
}
LoggerWrapper is wrapper around any third-party logger that implements any of the following interfaces:
# ExtendedLeveledLogger # ShortLeveledLogger # LeveledLogger # StdLogger
By wrapping the logger it implements ExtendedLeveledLogger. For loggers that implements only StdLogger, LoggerWrapper tries to virtualize leveled logger behaviour. It simply adds level name before logging message. If a logger implements LeveledLogger that doesn't have specific log line '****ln()' methods, it uses default non 'ln' functions - i.e. instead 'Infoln' uses 'Info'.
func MustGetLoggerWrapper ¶
func MustGetLoggerWrapper(logger interface{}) *LoggerWrapper
MustGetLoggerWrapper creates a LoggerWrapper wrapper over provided 'logger' argument. By default the function checks if provided logger implements logging interfaces in a following hierarchy:
# ExtendedLeveledLogger # ShortLeveledLogger # LeveledLogger # StdLogger
if logger doesn't implement an interface it tries to check the next in hierarchy. If it doesn't implement any of known logging interfaces the function panics.
func NewLoggerWrapper ¶
func NewLoggerWrapper(logger interface{}) (*LoggerWrapper, error)
NewLoggerWrapper creates a LoggerWrapper wrapper over provided 'logger' argument By default the function checks if provided logger implements logging interfaces in a following hierarchy:
# ExtendedLeveledLogger # ShortLeveledLogger # LeveledLogger # StdLogger
if logger doesn't implement an interface it tries to check the next in hierarchy. If it doesn't implement any of known logging interfaces the function returns error.
func (*LoggerWrapper) Debug ¶
func (c *LoggerWrapper) Debug(args ...interface{})
Debug logs a message with DEBUG level. Arguments are handled in the manner of log.Print for StdLogger, log.Debug for ExtendedLeveledLogger and LeveledLogger.
func (*LoggerWrapper) Debugf ¶
func (c *LoggerWrapper) Debugf(format string, args ...interface{})
Debugf logs a formatted message with DEBUG level. Arguments are handled in the manner of log.Printf for StdLogger, log.Debugf for ExtendedLeveledLogger, ShortLeveledLogger and LeveledLogger.
func (*LoggerWrapper) Debugln ¶
func (c *LoggerWrapper) Debugln(args ...interface{})
Debugln logs a message with DEBUG level. Arguments are handled in the manner of log.Println for StdLogger, log.Debugln for ExtendedLeveledLogger and log.Debug for LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Error ¶
func (c *LoggerWrapper) Error(args ...interface{})
Error logs a message with ERROR level. Arguments are handled in the manner of log.Print for StdLogger, log.Error for ExtendedLeveledLogger, LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Errorf ¶
func (c *LoggerWrapper) Errorf(format string, args ...interface{})
Errorf logs a formatted message with ERROR level. Arguments are handled in the manner of log.Printf for StdLogger, log.Errorf for ExtendedLeveledLogger, LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Errorln ¶
func (c *LoggerWrapper) Errorln(args ...interface{})
Errorln logs a message with ERROR level. Arguments are handled in the manner of log.Println for StdLogger, log.Debugln for ExtendedLeveledLogger and log.Error for LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Fatal ¶
func (c *LoggerWrapper) Fatal(args ...interface{})
Fatal logs a message with CRITICAL level. Afterwards it should excute os.Exit(1). Arguments are handled in the manner of log.Fatal for StdLogger, LeveledLogger, ShortLeveledLogger and ExtendedLeveledLogger.
func (*LoggerWrapper) Fatalf ¶
func (c *LoggerWrapper) Fatalf(format string, args ...interface{})
Fatalf logs a formatted message with CRITICAL level. Afterwards it should excute os.Exit(1). Arguments are handled in the manner of log.Fatalf for StdLogger, LeveledLogger, ShortLeveledLogger and ExtendedLeveledLogger.
func (*LoggerWrapper) Fatalln ¶
func (c *LoggerWrapper) Fatalln(args ...interface{})
Fatalln logs a message with CRITICAL level. Afterwards it should excute os.Exit(1). Arguments are handled in the manner of log.Fatalln for StdLogger and ExtendedLeveldLogger, and log.Fatal for LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Info ¶
func (c *LoggerWrapper) Info(args ...interface{})
Info logs a message with INFO level. Arguments are handled in the manner of log.Print for StdLogger, log.Info for ExtendedLeveledLogger, ShortLeveledLogger and LeveledLogger.
func (*LoggerWrapper) Infof ¶
func (c *LoggerWrapper) Infof(format string, args ...interface{})
Infof logs a formatted message with INFO level. Arguments are handled in the manner of log.Printf for StdLogger, log.Infof for ExtendedLeveledLogger, ShortLeveledLogger and LeveledLogger.
func (*LoggerWrapper) Infoln ¶
func (c *LoggerWrapper) Infoln(args ...interface{})
Infoln logs a message with INFO level. Arguments are handled in the manner of log.Println for StdLogger, log.Infoln for ExtendedLeveledLogger and log.Info for LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Panic ¶
func (c *LoggerWrapper) Panic(args ...interface{})
Panic logs a message with CRITICAL level. Afterwards it should panic. Arguments are handled in the manner of log.Panic for StdLogger, LeveledLogger, ShortLeveledLogger and ExtendedLeveledLogger .
func (*LoggerWrapper) Panicf ¶
func (c *LoggerWrapper) Panicf(format string, args ...interface{})
Panifc logs a formatted message with CRITICAL level. Afterwards it should panic. Arguments are handled in the manner of log.Panicf for StdLogger, LeveledLogger, ShortLeveledLogger and ExtendedLeveledLogger.
func (*LoggerWrapper) Panicln ¶
func (c *LoggerWrapper) Panicln(args ...interface{})
Panicln logs a message with CRITICAL level. Afterwards it should panic. Arguments are handled in the manner of log.Panicln for StdLogger and ExtendedLeveledLogger, and log.Panic LeveledLogger and ShortLeveledLogger.
func (*LoggerWrapper) Print ¶
func (c *LoggerWrapper) Print(args ...interface{})
Print logs a message. Arguments are handled in the manner of log.Print for StdLogger and Extended LeveledLogger as well as log.Info for LeveledLogger
func (*LoggerWrapper) Printf ¶
func (c *LoggerWrapper) Printf(format string, args ...interface{})
Printf logs a formatted message. Arguments are handled in the manner of log.Printf for StdLogger and Extended LeveledLogger as well as log.Infof for LeveledLogger
func (*LoggerWrapper) Println ¶
func (c *LoggerWrapper) Println(args ...interface{})
Println logs a message. Arguments are handled in the manner of log.Println for StdLogger and Extended LeveledLogger as well as log.Info for LeveledLogger
func (*LoggerWrapper) Warning ¶
func (c *LoggerWrapper) Warning(args ...interface{})
Warning logs a message with WARNING level. Arguments are handled in the manner of log.Print for StdLogger, log.Warning for ExtendedLeveledLogger, LeveledLogger and log.Warn for ShortLeveledLogger.
func (*LoggerWrapper) Warningf ¶
func (c *LoggerWrapper) Warningf(format string, args ...interface{})
Warningf logs a formatted message with WARNING level. Arguments are handled in the manner of log.Printf for StdLogger, log.Warningf for ExtendedLeveledLogger, LeveledLogger and log.Warnf for ShortLeveledLogger.
func (*LoggerWrapper) Warningln ¶
func (c *LoggerWrapper) Warningln(args ...interface{})
Warningln logs a message with WARNING level. Arguments are handled in the manner of log.Println for StdLogger, log.Warningln for ExtendedLeveledLogger, log.Warning for LeveledLogger and log.Warn for ShortLeveledLogger.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a basic logging record structure used in BasicLogger
type ShortLeveledLogger ¶
type ShortLeveledLogger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) }
ShortLeveledLogger is a logger that uses basic logging leveles with short name for Warn
type StdLogger ¶
type StdLogger interface { Print(args ...interface{}) Printf(format string, args ...interface{}) Println(args ...interface{}) Panic(args ...interface{}) Panicf(format string, args ...interface{}) Panicln(args ...interface{}) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Fatalln(args ...interface{}) }
StdLogger is the logger interface for standard log library