Documentation
¶
Index ¶
- Constants
- func Alert(message string, args ...any)
- func Critical(message string, args ...any)
- func Debug(message string, args ...any)
- func DisableColorOutput()
- func Emergency(message string, args ...any)
- func Error(message string, args ...any)
- func Information(message string, args ...any)
- func Notice(message string, args ...any)
- func SetLogColumnSeparator(separator string)
- func SetLogColumns(columns ...any)
- func SetLogLevel(level int)
- func Trace(message string, args ...any)
- func Warning(message string, args ...any)
Constants ¶
const ( LOG_LEVEL_EMERGENCY = iota LOG_LEVEL_ALERT LOG_LEVEL_CRITICAL LOG_LEVEL_ERROR LOG_LEVEL_WARNING LOG_LEVEL_NOTICE LOG_LEVEL_INFORMATIONAL LOG_LEVEL_DEBUG LOG_LEVEL_TRACE )
The Unix Syslog log levels complemented with a custom "trace" level.
const ( LOG_COLUMN_DATETIME = iota LOG_COLUMN_PID LOG_COLUMN_SOURCE LOG_COLUMN_LEVEL )
The default types of information the caller can configure the logger to print along with each log message. See "SetLogColumns" for details.
Variables ¶
This section is empty.
Functions ¶
func Alert ¶
Alert prints a log message for situations where an action must be taken immediately, say, for example, due to a corrup database. This function will not "panic()", allowing the process to do additional logging.
func Critical ¶
Critical prints a log message for critical errors, such as hardware device errors. This function will not "panic()", allowing the process to do additional logging.
func Debug ¶
Debug prints a log message which contains information that is normally useful only when debugging a program, for example an intermediate value of local variable.
func DisableColorOutput ¶
func DisableColorOutput()
DisableColorOutput prevents the logs from sending color control characters to the output stream.
Color output is usually enabled by default, unless it is actively disabled by FORCE_COLOR or NO_COLOR environment variables. This logger honors said variables without the caller having to explicitly call this method.
Furthermore, this logger will also disable color output when log output is redirected (through any of the ">" directives) to a different destination than the terminal.
func Emergency ¶
Emergency prints a panic mode log message. These logs are usually printed when the system is unusable due to a panic situation. This function will not actually "panic()", allowing the process to do additional logging or tombstone aggregation.
func Error ¶
Error prints a log message for serious errors that may cause a degrade in functionality or even data loss without having to halt execution, for example a full disk. This function will not "panic()", allowing the process to do additional logging.
func Information ¶
Information prints a log message that confirms expected execution, for example when data has been successfully saved.
func Notice ¶
Notice prints a log message for situations that are normal but needs special handling, for example when requesting a network resource that is temporarily unavailable.
func SetLogColumnSeparator ¶
func SetLogColumnSeparator(separator string)
SetLogColumnSeparator defines how the log info columns are separated. If the logs are to be machine processed at a later time, this function enables producing, say, a CSV file by setting the separator ";" or "\t".
func SetLogColumns ¶
func SetLogColumns(columns ...any)
SetLogColumns will alter the information being printed before each log message. This function takes either a "LOG_COLUMN_..." constant that describes one of the standard log parameters, or a function that takes no arguments but produces a string "func() string" in order to log custom information.
func SetLogLevel ¶
func SetLogLevel(level int)
SetLogLevel constrains which logs to print. All log categories associated with a log level lower than or equal to the value being defined here will be sent to the output streams.
Types ¶
This section is empty.