Documentation
¶
Index ¶
- Constants
- func Debugf(format string, a ...interface{})
- func Debugln(message string)
- func Errorf(format string, a ...interface{})
- func Errorln(message string)
- func Infof(format string, a ...interface{})
- func Infoln(message string)
- func SetColor(level Level, color string)
- func SetDefaultColors()
- func SetDefaultOutput()
- func SetDefaultTemplate()
- func SetDefaultTimeFormat()
- func SetOutput(level Level, file *os.File)
- func SetTemplate(template string)
- func SetTimeFormat(format string)
- func Toggle(level Level, toggle bool)
- type Level
- type Logger
- func (l *Logger) Debugf(format string, a ...interface{})
- func (l *Logger) Debugln(message string)
- func (l *Logger) Errorf(format string, a ...interface{})
- func (l *Logger) Errorln(message string)
- func (l *Logger) Infof(format string, a ...interface{})
- func (l *Logger) Infoln(message string)
- func (l *Logger) SetColor(level Level, color string)
- func (l *Logger) SetDefaultColors()
- func (l *Logger) SetDefaultOutput()
- func (l *Logger) SetDefaultTemplate()
- func (l *Logger) SetDefaultTimeFormat()
- func (l *Logger) SetOutput(level Level, file *os.File)
- func (l *Logger) SetTemplate(template string)
- func (l *Logger) SetTimeFormat(format string)
- func (l *Logger) Toggle(level Level, toggle bool)
Constants ¶
const ( // ANSI color codes Reset = "\033[0m" Black = "\033[30m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Purple = "\033[35m" Cyan = "\033[36m" White = "\033[37m" )
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, a ...interface{})
Print the formatted message to the debug level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func Debugln ¶
func Debugln(message string)
Print the message to the debug level output. The message always ends in a new line.
func Errorf ¶
func Errorf(format string, a ...interface{})
Print the formatted message to the error level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func Errorln ¶
func Errorln(message string)
Print the message to the error level output. The message always ends in a new line.
func Infof ¶
func Infof(format string, a ...interface{})
Print the formatted message to the info level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func Infoln ¶
func Infoln(message string)
Print the message to the info level output. The message always ends in a new line.
func SetDefaultOutput ¶
func SetDefaultOutput()
Sets the default output files used by the logger (Stdout for DEBUG and INFO, Stderr for ERROR).
func SetDefaultTemplate ¶
func SetDefaultTemplate()
Sets the default template used by the logger. text/template is used to format the output.
func SetDefaultTimeFormat ¶
func SetDefaultTimeFormat()
Sets the time format to the default format used by the logger.
func SetTemplate ¶
func SetTemplate(template string)
Sets the template used by the logger. text/template is used to format the output. Default template: {{ .Time }} [{{ .Color }}{{ .Level }}{{ .Reset }}] {{ .Message }}
The following variables are available:
.Time: The current time formatted using the time format. Format can be set using SetTimeFormat.
.Color: The ANSI color for the level.
.Level: The level as string.
.Reset: The ANSI reset code.
.Message: The message.
func SetTimeFormat ¶
func SetTimeFormat(format string)
Sets the time format used by the logger (time.Now().Format(format)).
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) Debugf ¶
Print the formatted message to the debug level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func (*Logger) Debugln ¶
Print the message to the debug level output. The message always ends in a new line.
func (*Logger) Errorf ¶
Print the formatted message to the error level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func (*Logger) Errorln ¶
Print the message to the error level output. The message always ends in a new line.
func (*Logger) Infof ¶
Print the formatted message to the info level output. The message is formatted using fmt.Sprintf and always ends in a new line.
func (*Logger) Infoln ¶
Print the message to the info level output. The message always ends in a new line.
func (*Logger) SetDefaultColors ¶
func (l *Logger) SetDefaultColors()
func (*Logger) SetDefaultOutput ¶
func (l *Logger) SetDefaultOutput()
func (*Logger) SetDefaultTemplate ¶
func (l *Logger) SetDefaultTemplate()
Sets the template to the default template used by the logger. Uses text/template to format the message.
Default template: {{ .Time }} [{{ .Color }}{{ .Level }}{{ .Reset }}] {{.Message}}
func (*Logger) SetDefaultTimeFormat ¶
func (l *Logger) SetDefaultTimeFormat()
Sets the time format to the default format used by the logger.
func (*Logger) SetTemplate ¶
Sets the template used by the logger. Uses text/template to format the message.
func (*Logger) SetTimeFormat ¶
Sets the time format used by the logger (time.Now().Format(format)).