Documentation ¶
Overview ¶
logger provides basic logging support for your application. Supported log destinations are the console and a log file
Index ¶
- func CloseFile()
- func Debug(message string, parameters ...any)
- func Error(message string, parameters ...any)
- func Fatal(message string, parameters ...any)
- func Info(message string, parameters ...any)
- func SetGlobalLogger(l *Logger)
- func Trace(message string, parameters ...any)
- func Warning(message string, parameters ...any)
- type Level
- type Logger
- func (l *Logger) CloseFile()
- func (l Logger) Debug(message string, parameters ...any)
- func (l Logger) Error(message string, parameters ...any)
- func (l Logger) Fatal(message string, parameters ...any)
- func (l Logger) Info(message string, parameters ...any)
- func (l *Logger) Log(level Level, message string, parameters ...any)
- func (l Logger) Trace(message string, parameters ...any)
- func (l Logger) Warning(message string, parameters ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseFile ¶
func CloseFile()
CloseFile closes the underlaying file to which the logger messages are written.
func SetGlobalLogger ¶
func SetGlobalLogger(l *Logger)
SetGlobalLogger updates the global default logger with a custom one. You can create one via the Logger struct.
Types ¶
type Level ¶
type Level uint8
Level of the log message
func GetLevelByName ¶
GetLevelByName tries to convert the given level name to the represented level code. Allowed values are: 'trace', 'debug', 'info', 'warn', 'warning', 'error', 'panic' and 'fatal' If an incorrect level name was given an warning is logged and info will be returned
type Logger ¶
type Logger struct { PrintLevel Level LogLevel Level LogFilePath string PrintSource bool // Colorizes the log messages for the console. // Even if you set this to true the user is able to overwrite this behaviour by // setting the environment variables "TERMINAL_DISABLE_COLORS" and // "TERMINAL_ENABLE_COLORS" (to force coloring for "unsupported" terminals) ColoredOutput bool // While logging, the file and line number of the // invoking (calling) line can be printed out. // This defines an offset that is applied to the call stack. // If you you are using an own wrapper function, you // have to set this value to one FuncCallIncrement int // contains filtered or unexported fields }
func GetGlobalLogger ¶
func GetGlobalLogger() *Logger
func NewLoggerWithFile ¶
NewLoggerWithFile creates a new instance with the given logger configuration. Instead of opening a new file to write the log messages to, the old file reference of the other logger will be used internal. This enables you to writhe to the same file with different log configurations.