Documentation ¶
Overview ¶
package log provides a simple logger with leveled log messages.
- DebugLevel (highest verbosity)
- InfoLevel
- WarningLevel
- ErrorLevel
- FatalLevel (lowest verbosity)
Output is by default written to STDERR. A different output can be specified. Dates and terminal colors can be turned on.
Example ¶
SetOutput(os.Stdout) SetLevel(WarningLevel) SetDate(false) SetColor(false) Debug("some debug number: %d\n", 10) Info("some info number: %d\n", 20) Warning("some warning number: %d\n", 30) Error("some error number: %d\n", 40)
Output: [WARN] some warning number: 30 [ERRO] some error number: 40
Index ¶
- Constants
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func SetColor(ok bool)
- func SetDate(ok bool)
- func SetLevel(lv level)
- func SetOutput(writer io.Writer)
- func Warning(format string, v ...interface{})
Examples ¶
Constants ¶
View Source
const ( DebugLevel level = iota // DebugLevel logs all messages InfoLevel // InfoLevel logs info messages and and above WarningLevel // WarningLevel logs warning messages and above ErrorLevel // ErrorLevel logs error messages and above FatalLevel // FatalLevel only logs fatal messages )
Variables ¶
This section is empty.
Functions ¶
func SetLevel ¶
func SetLevel(lv level)
SetLevel sets the logging level. Available options: DebugLevel, InfoLevel, WarningLevel, ErrorLevel, FatalLevel.
func SetOutput ¶
SetOutput sets the logging output to a particular writer.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.