Documentation
¶
Index ¶
Constants ¶
const LogLevelsValues = `"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "ALL"`
LogLevelsValues is a constant that is intended to be used to describe which values are accepted inside the LogLevels string.
When building CLI tools, use this constant to provide "--help" information about the flag that controls the log levels
Variables ¶
This section is empty.
Functions ¶
func ParseLogLevel ¶ added in v1.2.0
ParseLogLevel will take a string (usually from the CLI flag arguments) and returns the equivalent uint64 that enables the selected log levels.
You can set some CLI flag that accepts human-readable log level selection, using the "|" separator. The following imaginary flag value, for example, will enable the DEBUG, TRACE and WARN log levels:
--log-levels="DEBUG|TRACE|WARN"
Note that the string is not expected to have blank spaces in between the selected log levels
This function accepts an extra string representing all the log levels: "ALL". If the string contains "ALL", or is equal to "ALL", all the log levels will be enabled
func ValidateLogLevels ¶ added in v1.3.0
ValidateLogLevels will take some string and check to see if it's a valid LogLevels string.
If the string contains anything not recognizable as a LogLevel, the returned value will be false. Otherwise, returns true and the string is safe to be used.
Note that you can use this function to validate some CLI flag value.
Types ¶
type LoggerCLI ¶
type LoggerCLI interface { Trace(format string, args ...interface{}) LoggerCLI Debug(format string, args ...interface{}) LoggerCLI Info(format string, args ...interface{}) LoggerCLI Warn(format string, args ...interface{}) LoggerCLI Error(format string, args ...interface{}) LoggerCLI Fatal(format string, args ...interface{}) ErrorFrom(e error) LoggerCLI FatalFrom(e error) }