Documentation ¶
Overview ¶
Package logger provides a logging framework similar to those of python and haskell.
Index ¶
- Variables
- func ImportLoggers(lo map[Logger]string) (err error)
- func NamePriority(pr Priority) (pri string, err error)
- func SetFormat(lo Logger, fo Format) error
- func SetLevel(lo Logger, pr Priority) (err error)
- func SetNoColor(lo Logger, nc bool)
- func SetOutput(lo Logger, ou io.Writer) error
- func SetTimeFormat(lo Logger, fo string) error
- type Format
- type Logger
- func (lo Logger) Alert(me ...interface{})
- func (lo Logger) Critical(me ...interface{})
- func (lo Logger) Debug(me ...interface{})
- func (lo Logger) Emergency(me ...interface{})
- func (lo Logger) Error(me ...interface{})
- func (lo Logger) GetLevel() Priority
- func (lo Logger) Info(me ...interface{})
- func (lo Logger) Log(pr Priority, me ...interface{})
- func (lo Logger) Notice(me ...interface{})
- func (lo Logger) SetFormat(fo Format)
- func (lo Logger) SetLevel(pr Priority) (err error)
- func (lo Logger) SetNoColor(nc bool)
- func (lo Logger) SetOutput(ou io.Writer)
- func (lo Logger) SetTimeFormat(fo string) error
- func (lo Logger) Trace(me ...interface{})
- func (lo Logger) Warning(me ...interface{})
- type Priority
Constants ¶
This section is empty.
Variables ¶
var ( // SaveLoggerLevels will make the package save loggers which are only defined // by their parents if it is set to true. SaveLoggerLevels = true )
Functions ¶
func ImportLoggers ¶
ImportLoggers sets the LogLevel for the given Loggers.
func NamePriority ¶
NamePriority returns the string value of the given priority.
func SetFormat ¶
SetFormat changes the message format for the given logger. Avaivable fields are:
Time: The time when the message is printed.
Logger: The name of the logger.
Priority: The priority of the logger.
Message: The output message.
The default Format is:
"[{{.Time}} {{.Logger}} {{.Priority}}] - {{.Message}}.\n"
func SetNoColor ¶
SetNoColor sets the nocolor flag for the given logger. If true no colors will be printed for the logger.
func SetOutput ¶
SetOutput sets the output parameter of the logger to the given io.Writer. The default is os.Stderr.
func SetTimeFormat ¶
SetTimeFormat sets the TimeFormat which will be used in the message format for the specified logger
The default format is: RFC3339
Types ¶
type Format ¶
type Format string
Format represents the format which will be used to print the message for an logger.
type Logger ¶
type Logger string
Logger represent different lognames and priorities. They can have parents and child loggers which will inherit the priority of the parent if it has none. The hirachy of loggers is represented through sepperation with dots ('.'). The root logger has the name '.'.
func (Logger) Alert ¶
func (lo Logger) Alert(me ...interface{})
Alert logs a message with the Debug priority.
func (Logger) Critical ¶
func (lo Logger) Critical(me ...interface{})
Critical logs a message with the Debug priority.
func (Logger) Debug ¶
func (lo Logger) Debug(me ...interface{})
Debug logs a message with the Debug priority.
func (Logger) Emergency ¶
func (lo Logger) Emergency(me ...interface{})
Emergency logs a message with the Debug priority.
func (Logger) Error ¶
func (lo Logger) Error(me ...interface{})
Error logs a message with the Debug priority.
func (Logger) Info ¶
func (lo Logger) Info(me ...interface{})
Info logs a message with the Debug priority.
func (Logger) Notice ¶
func (lo Logger) Notice(me ...interface{})
Notice logs a message with the Debug priority.
func (Logger) SetFormat ¶
SetFormat changes the message format for the Logger. Avaivable fields are:
Time: The time when the message is printed.
Logger: The name of the logger.
Priority: The priority of the logger.
Message: The output message.
The default Format is:
"[{{.Time}} {{.Logger}} {{.Priority}}] - {{.Message}}.\n"
func (Logger) SetNoColor ¶
SetNoColor sets the nocolor flag for the given logger. If true no colors will be printed for the logger.
func (Logger) SetOutput ¶
SetOutput sets the output parameter of the logger to the given io.Writer. The default is os.Stderr.
func (Logger) SetTimeFormat ¶
SetTimeFormat sets the TimeFormat which will be used in the message format for the Logger
The default format is: RFC3339
type Priority ¶
type Priority int
Priority defines how important a log message is. Loggers will output messages which are above their priority level.
Different priority levels ordered by their severity.
DefaultPriority of the root logger.
func ParsePriority ¶
ParsePriority tries to parse the priority by the given string.