Documentation
¶
Overview ¶
Package logger provides a custom logging abstract over the standard out logging of golang. All logging should by go to stdout according to 12-factor principles. Logging levels are based on RFC 5424: http://www.rfc-base.org/rfc-5424.html#
Index ¶
- Constants
- Variables
- type Logger
- func (l *Logger) Alertf(format string, v ...interface{})
- func (l *Logger) Criticalf(format string, v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Emergencyf(format string, v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) GetLogLevel() int
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Noticef(format string, v ...interface{})
- func (l *Logger) Output(cd int, lbl string, format string, v ...interface{}) error
- func (l *Logger) SetColouredLabels()
- func (l *Logger) SetExitFunc(e exiter) error
- func (l *Logger) SetLogLevel(lvl int) error
- func (l *Logger) SetPlainLabels()
- func (l *Logger) Warningf(format string, v ...interface{})
Constants ¶
const ( // RFC 5424 log levels. Emergency = iota Alert Critical Error Warning Notice Info Debug UseDefault = -1 // Note: literal consts must follow any iota decls else unexpected results. )
Standard labels.
Variables ¶
var ( // Log labels. Labels = []string{"[EMERGENCY] ", "[ALERT] ", "[CRITICAL] ", "[ERROR] ", "[WARNING] ", "[NOTICE] ", "[INFO] ", "[DEBUG] ", } )
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a datastructure for all logging state.
func (*Logger) Emergencyf ¶
Emergencyf prints an emergency message to the system log, This is considered an unrecoverable error and the application also exits, unless dont exit = true.
func (*Logger) GetLogLevel ¶
GetLogLevel returns the current log level of the logger.
func (*Logger) Output ¶
Output prints a message directly into the system log. Normally, you should use level message functions. so that level can trap the write.
func (*Logger) SetColouredLabels ¶
func (l *Logger) SetColouredLabels()
SetColouredLabels sets the message labels to colourized text output.
func (*Logger) SetExitFunc ¶
SetExitFunc allows a user to set the exit function of the logger.
func (*Logger) SetLogLevel ¶
SetLogLevel allows a user to set the log level of the logger.
func (*Logger) SetPlainLabels ¶
func (l *Logger) SetPlainLabels()
SetPlainLabels sets the message labels to simple text output.