Documentation ¶
Overview ¶
glog aims to be the "one for all" logging package. It has a wide variety of features. To "handle errors gracefully" most times when a Setting-Function is called, no error is returned. If the specified level does not exist, execution is just silently aborted.
An important note is that *all* log-level ranges are inclusive. This means that "below …" actually means "below or equal to …".
Index ¶
- Variables
- func AddLogFile(filepath string, lvls ...Level) (*os.File, error)
- func AddOutput(lvl Level, output io.Writer)
- func AddOutputAbove(lvl Level, output io.Writer)
- func AddOutputBelow(lvl Level, output io.Writer)
- func AddOutputBetween(lowerLevel, upperLevel Level, output io.Writer)
- func Debug(message ...interface{})
- func Debugf(format string, values ...interface{})
- func Error(message ...interface{})
- func Errorf(format string, values ...interface{})
- func Fatal(message ...interface{})
- func Fatalf(format string, values ...interface{})
- func Info(message ...interface{})
- func Infof(format string, values ...interface{})
- func PlainStyle(content ...interface{}) string
- func SetOutput(lvl Level, output io.Writer)
- func SetOutputAbove(lvl Level, output io.Writer)
- func SetOutputBelow(lvl Level, output io.Writer)
- func SetOutputBetween(lowerLevel, upperLevel Level, output io.Writer)
- func SetShowCaller(lvl Level, show bool)
- func SetStyle(lvl Level, styler StyleFunction)
- func Trace(message ...interface{})
- func Tracef(format string, values ...interface{})
- func Warn(message ...interface{})
- func Warnf(format string, values ...interface{})
- type Level
- type StyleFunction
Constants ¶
This section is empty.
Variables ¶
var ( // OverwriteColor allows overwriting the coloring mode. 0 = auto; // 1 = always; -1 = never // // This can also be set using the Environment-variable `GLOG_COLOR` OverwriteColor int8 // LogLevel indicates the level of verbosity to use when logging. // Messages below the specified level are discarded. // // This can also be set using the Environment-variable `GLOG_LEVEL` LogLevel = WARNING )
var ( // TimeFormat specifies the formatting of the timestamp to use. The // default is ISO-8601 which corresponds to: TimeFormat = "2006-01-02T15:04:05-0700" )
Functions ¶
func AddOutputAbove ¶
AddOutput adds the specified output to the list of outputs for the specified levels.
func AddOutputBelow ¶
AddOutput adds the specified output to the list of outputs for the specified levels.
func AddOutputBetween ¶
AddOutputBetween adds the specified output to the list of outputs for all specified levels.
func Debugf ¶
func Debugf(format string, values ...interface{})
Debugf formats the input values as specified and writes them to the according channels
func Errorf ¶
func Errorf(format string, values ...interface{})
Errorf formats the input values as specified and writes them to the according channels
func Fatal ¶
func Fatal(message ...interface{})
Fatal logs a message at the FATAL level and Panics afterwards
func Fatalf ¶
func Fatalf(format string, values ...interface{})
Fatalf formats the input values as specified and writes them to the according channels
func Infof ¶
func Infof(format string, values ...interface{})
Infof formats the input values as specified and writes them to the according channels
func PlainStyle ¶
func PlainStyle(content ...interface{}) string
PlainStyle is an implementation of StyleFunction that does not format output.
func SetOutput ¶
SetOutput removes all outputs and replaces them with the specified output. To discard log messages to this level set the loglevel accordingly or use `io.Discard`
func SetOutputAbove ¶
SetOutputAbove removes all outputs and replaces them with the specified output. This is repeated for every specified level.
func SetOutputBelow ¶
SetOutput removes all outputs and replaces them with the specified output. This is repeated for every specified level.
func SetOutputBetween ¶
SetOutputBetween removes all outputs and replaces them with the specified output. This is executed for all specified levels.
func SetShowCaller ¶
func SetStyle ¶
func SetStyle(lvl Level, styler StyleFunction)
SetStyle allows customizing the look of the *error-level*. This can also be used for changing the names of the loglevels.
Types ¶
type StyleFunction ¶
type StyleFunction func(...interface{}) string
StyleFunction is a kind of function that is used for styling. I know, who would have thought.