Documentation
¶
Overview ¶
Package log implements a leveled logging system. It checks the current log level and decides whether to print the logging texts or ignore them.
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(msg string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(msg string, args ...interface{})
- func Info(args ...interface{})
- func Infof(msg string, args ...interface{})
- func Log(level LogLevel, args ...interface{})
- func Logf(level LogLevel, msg string, args ...interface{})
- func SetLevelFromStr(s string)
- func SetOutput(w io.Writer)
- func Warning(args ...interface{})
- func Warningf(msg string, args ...interface{})
- type LogLevel
Constants ¶
const DefaultLevel = WARNING
DefaultLevel defines the default log level
Variables ¶
var ( // SetLevel is the wrapper for the global logger SetLevel = globalLevel.SetLevel // Level is the wrapper for the global logger Level = globalLevel.Level )
var LevelStr = []string{ DEBUG: "DEBUG", INFO: "INFO", WARNING: "WARN", ERROR: "ERROR", }
LevelStr represents the log levels in strings
Functions ¶
func Debugf ¶
func Debugf(msg string, args ...interface{})
Debugf formats the log message with specified args and print it in the specified level
func Errorf ¶
func Errorf(msg string, args ...interface{})
Errorf formats the log message with specified args and print it in the specified level
func Infof ¶
func Infof(msg string, args ...interface{})
Infof formats the log message with specified args and print it in the specified level
func Log ¶
func Log(level LogLevel, args ...interface{})
Log prints the log message in the specified level
func SetLevelFromStr ¶
func SetLevelFromStr(s string)
SetLevelFromStr parses the input string to a LogLevel and change the level of the global logger accordingly.
Types ¶
type LogLevel ¶
type LogLevel uint8
LogLevel is a type that defines the log level.
func StrToLevel ¶
StrToLevel converts a log level in string format (e.g., "DEBUG") to the corresponding log level in LogLevel type. It returns ERROR (the highest level) and an error for invalid log level strings.
func ToLogLevel ¶
ToLogLevel converts a string to a log level, or returns false for any error