Add a method per logging level to logger struct

main v1.0.2
Jonas Letzbor 2023-04-09 09:44:08 +02:00
parent 6c40c672c8
commit 331e5a7d7b
Signed by: RPJosh
GPG Key ID: 46D72F589702E55A
1 changed files with 23 additions and 0 deletions

View File

@ -219,6 +219,8 @@ func GetGlobalLogger() *Logger {
return &dLogger
}
// Global available methods per logging levels //
func Trace(message string, parameters ...any) {
dLogger.Log(LevelTrace, message, parameters...)
}
@ -238,6 +240,27 @@ func Fatal(message string, parameters ...any) {
dLogger.Log(LevelFatal, message, parameters...)
}
// Available methods for each logger per logging level //
func (l Logger) Trace(message string, parameters ...any) {
l.Log(LevelTrace, message, parameters...)
}
func (l Logger) Debug(message string, parameters ...any) {
l.Log(LevelDebug, message, parameters...)
}
func (l Logger) Info(message string, parameters ...any) {
l.Log(LevelInfo, message, parameters...)
}
func (l Logger) Warning(message string, parameters ...any) {
l.Log(LevelWarning, message, parameters...)
}
func (l Logger) Error(message string, parameters ...any) {
l.Log(LevelError, message, parameters...)
}
func (l Logger) Fatal(message string, parameters ...any) {
l.Log(LevelFatal, message, parameters...)
}
// CloseFile closes the underlaying file to which the logger messages are written.
func CloseFile() {
dLogger.CloseFile()