From 504926c7cda162c75c3e92b6cf3dbde78dfc62cb Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Sat, 5 Oct 2024 10:39:49 +0200 Subject: [PATCH] fix: logging time --- utils/logger.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/logger.go b/utils/logger.go index cd84a3e..76ce3b2 100644 --- a/utils/logger.go +++ b/utils/logger.go @@ -12,9 +12,8 @@ import ( "time" ) -var currentTime = time.Now().Format("2006/01/02 15:04:05") - func Info(msg string, args ...any) { + var currentTime = time.Now().Format("2006/01/02 15:04:05") formattedMessage := fmt.Sprintf(msg, args...) if len(args) == 0 { fmt.Printf("%s INFO: %s\n", currentTime, msg) @@ -25,6 +24,7 @@ func Info(msg string, args ...any) { // Warn warning message func Warn(msg string, args ...any) { + var currentTime = time.Now().Format("2006/01/02 15:04:05") formattedMessage := fmt.Sprintf(msg, args...) if len(args) == 0 { fmt.Printf("%s WARN: %s\n", currentTime, msg) @@ -33,6 +33,7 @@ func Warn(msg string, args ...any) { } } func Error(msg string, args ...any) { + var currentTime = time.Now().Format("2006/01/02 15:04:05") formattedMessage := fmt.Sprintf(msg, args...) if len(args) == 0 { fmt.Printf("%s ERROR: %s\n", currentTime, msg) @@ -41,6 +42,7 @@ func Error(msg string, args ...any) { } } func Done(msg string, args ...any) { + var currentTime = time.Now().Format("2006/01/02 15:04:05") formattedMessage := fmt.Sprintf(msg, args...) if len(args) == 0 { fmt.Printf("%s INFO: %s\n", currentTime, msg) @@ -51,6 +53,7 @@ func Done(msg string, args ...any) { // Fatal logs an error message and exits the program func Fatal(msg string, args ...any) { + var currentTime = time.Now().Format("2006/01/02 15:04:05") // Fatal logs an error message and exits the program. formattedMessage := fmt.Sprintf(msg, args...) if len(args) == 0 {