loggerCLI

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
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

func ParseLogLevel(str string) uint64

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

func ValidateLogLevels(s string) bool

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)
}

func New

func New(json bool, lvlsEnabled uint64) LoggerCLI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL