Documentation
¶
Index ¶
- Constants
- type CompatibleLogger
- type FileLogger
- func (fl *FileLogger) Debugf(format string, v ...interface{})
- func (fl *FileLogger) DeferredFatalf(format string, v ...interface{})
- func (fl *FileLogger) Errorf(format string, v ...interface{})
- func (fl *FileLogger) Fatalf(format string, v ...interface{})
- func (fl *FileLogger) Infof(format string, v ...interface{})
- func (fl *FileLogger) SetLoggingLevel(level uint8)
- func (fl *FileLogger) Warnf(format string, v ...interface{})
- type Logger
- type MultiLogger
- func (ml *MultiLogger) Debugf(format string, args ...interface{})
- func (ml *MultiLogger) DeferredFatalf(format string, args ...interface{})
- func (ml *MultiLogger) Errorf(format string, args ...interface{})
- func (ml *MultiLogger) Fatalf(format string, args ...interface{})
- func (ml *MultiLogger) Infof(format string, args ...interface{})
- func (ml *MultiLogger) Warnf(format string, args ...interface{})
- type StdoutLogger
- func (sl *StdoutLogger) Debugf(format string, v ...interface{})
- func (sl *StdoutLogger) DeferredFatalf(format string, v ...interface{})
- func (sl *StdoutLogger) Errorf(format string, v ...interface{})
- func (sl *StdoutLogger) Fatalf(format string, v ...interface{})
- func (sl *StdoutLogger) Infof(format string, v ...interface{})
- func (sl *StdoutLogger) SetLoggingLevel(level uint8)
- func (sl *StdoutLogger) Warnf(format string, v ...interface{})
Constants ¶
const ( LOG_DEBUG uint8 = iota // lowest logging level, all debug details will be logged LOG_INFO LOG_WARN LOG_ERROR LOG_FATAL LOG_NOLOG // highest logging level, no log will be written, but Fatalf will still exit the program )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompatibleLogger ¶
type CompatibleLogger interface {
Logger
DeferredFatalf(format string, args ...interface{}) // should not call os.Exit but do the rest of the work.
}
CompatibleLogger is used for internal logger chaining/combining.
type FileLogger ¶
type FileLogger struct {
// contains filtered or unexported fields
}
FileLogger defines a logger that writes to a file. It implements the Logger interface.
func DefaultFileLogger ¶
func DefaultFileLogger(filename string, loggingLevel uint8) *FileLogger
DefaultFileLogger creates a new FileLogger with the given filename at the given logging level. It sets the prefix to "" and the flag to log.LstdFlags.
func NewFileLogger ¶
func NewFileLogger(filename string, prefix string, flag int) *FileLogger
NewFileLogger creates a new FileLogger with the given filename, prefix and flag.
func (*FileLogger) Debugf ¶
func (fl *FileLogger) Debugf(format string, v ...interface{})
Debugf implements the Logger interface.
func (*FileLogger) DeferredFatalf ¶
func (fl *FileLogger) DeferredFatalf(format string, v ...interface{})
DeferredFatalf implements the CompatibleLogger interface. It does everything that Fatalf does, except it does not call os.Exit(1).
func (*FileLogger) Errorf ¶
func (fl *FileLogger) Errorf(format string, v ...interface{})
Errorf implements the Logger interface.
func (*FileLogger) Fatalf ¶
func (fl *FileLogger) Fatalf(format string, v ...interface{})
Fatalf implements the Logger interface. It calls os.Exit(1) after logging regardless of the logging level.
func (*FileLogger) Infof ¶
func (fl *FileLogger) Infof(format string, v ...interface{})
Infof implements the Logger interface.
func (*FileLogger) SetLoggingLevel ¶
func (fl *FileLogger) SetLoggingLevel(level uint8)
SetLoggingLevel sets the logging level for the logger. The logging level is expected to be one of the following:
LOG_DEBUG LOG_INFO LOG_WARN LOG_ERROR LOG_FATAL LOG_NOLOG
func (*FileLogger) Warnf ¶
func (fl *FileLogger) Warnf(format string, v ...interface{})
Warnf implements the Logger interface.
type Logger ¶
type Logger 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{})
}
Logger defines an interface for logging output. Debugf, Infof, Warnf, Errorf, and Fatalf are the logging functions. The Fatalf function will call os.Exit(1) after logging, even when logging level is higher than LOG_FATAL.
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
MultiLogger combines multiple loggers into one. Implements CompatibleLogger interface -- could be further chained.
func NewMultiLogger ¶
func NewMultiLogger(loggers ...CompatibleLogger) *MultiLogger
func (*MultiLogger) Debugf ¶
func (ml *MultiLogger) Debugf(format string, args ...interface{})
Debugf implements Logger interface.
func (*MultiLogger) DeferredFatalf ¶
func (ml *MultiLogger) DeferredFatalf(format string, args ...interface{})
func (*MultiLogger) Errorf ¶
func (ml *MultiLogger) Errorf(format string, args ...interface{})
Errorf implements Logger interface.
func (*MultiLogger) Fatalf ¶
func (ml *MultiLogger) Fatalf(format string, args ...interface{})
Fatalf implements Logger interface.
func (*MultiLogger) Infof ¶
func (ml *MultiLogger) Infof(format string, args ...interface{})
Infof implements Logger interface.
func (*MultiLogger) Warnf ¶
func (ml *MultiLogger) Warnf(format string, args ...interface{})
Warnf implements Logger interface.
type StdoutLogger ¶
type StdoutLogger struct {
// contains filtered or unexported fields
}
StdoutLogger defines a logger that writes to stdout or stderr. It implements the Logger interface.
func DefaultStderrLogger ¶
func DefaultStderrLogger(loggingLevel uint8) *StdoutLogger
DefaultStderrLogger returns a new StdoutLogger that writes to stderr with no prefix and log.LstdFlags flag. It sets the logging level as specified.
func NewStderrLogger ¶
func NewStderrLogger(prefix string, flag int) *StdoutLogger
NewStderrLogger returns a new StdoutLogger that writes to stderr with specified prefix and flag. See log package from standard library for information about prefix and flag.
func NewStdoutLogger ¶
func NewStdoutLogger(prefix string, flag int) *StdoutLogger
NewStdoutLogger returns a new StdoutLogger that writes to stdout with specified prefix and flag. See log package from standard library for information about prefix and flag.
func (*StdoutLogger) Debugf ¶
func (sl *StdoutLogger) Debugf(format string, v ...interface{})
Debugf implements the Logger interface. It prints the message type in blue when logging level is set to LOG_DEBUG.
func (*StdoutLogger) DeferredFatalf ¶
func (sl *StdoutLogger) DeferredFatalf(format string, v ...interface{})
DeferredFatalf implements the CompatibleLogger interface. It does everything that Fatalf does, except it does not call os.Exit(1).
func (*StdoutLogger) Errorf ¶
func (sl *StdoutLogger) Errorf(format string, v ...interface{})
Errorf implements the Logger interface. It prints the message type in red when logging level is set to LOG_ERROR or lower.
func (*StdoutLogger) Fatalf ¶
func (sl *StdoutLogger) Fatalf(format string, v ...interface{})
Fatalf implements the Logger interface. It prints the full message in red when logging level is set to LOG_FATAL or lower. It calls os.Exit(1) regardless of the logging level.
func (*StdoutLogger) Infof ¶
func (sl *StdoutLogger) Infof(format string, v ...interface{})
Infof implements the Logger interface. It prints the message type in green when logging level is set to LOG_INFO or lower.
func (*StdoutLogger) SetLoggingLevel ¶
func (sl *StdoutLogger) SetLoggingLevel(level uint8)
SetLoggingLevel sets the logging level for the logger. The logging level is expected to be one of the following:
LOG_DEBUG LOG_INFO LOG_WARN LOG_ERROR LOG_FATAL LOG_NOLOG
func (*StdoutLogger) Warnf ¶
func (sl *StdoutLogger) Warnf(format string, v ...interface{})
Warnf implements the Logger interface. It prints the message type in yellow when logging level is set to LOG_WARN or lower.