From 6aac24d118438bd040b7e22e261a6e8abdfc83f7 Mon Sep 17 00:00:00 2001 From: Settel Date: Sun, 6 Nov 2022 17:07:35 +0100 Subject: [PATCH] feat: prepend log messages with prefix --- server/src/log/log.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/log/log.go b/server/src/log/log.go index 9594cb1..59c10ef 100644 --- a/server/src/log/log.go +++ b/server/src/log/log.go @@ -15,12 +15,16 @@ func SetLoglevel(_loglevel int) { loglevel = _loglevel } +func logWithPrefix(message string) { + fmt.Printf("knowyt: %s", message) +} + func Debug(format string, v ...any) { lock.Lock() defer lock.Unlock() if loglevel >= LOG_DEBUG { - fmt.Printf(format, v...) + logWithPrefix(fmt.Sprintf(format, v...)) } } @@ -29,7 +33,7 @@ func Info(format string, v ...any) { defer lock.Unlock() if loglevel >= LOG_INFO { - fmt.Printf(format, v...) + logWithPrefix(fmt.Sprintf(format, v...)) } } @@ -38,7 +42,7 @@ func Warn(format string, v ...any) { defer lock.Unlock() if loglevel >= LOG_WARN { - fmt.Printf(format, v...) + logWithPrefix(fmt.Sprintf(format, v...)) } } @@ -47,7 +51,7 @@ func Error(format string, v ...any) { defer lock.Unlock() if loglevel >= LOG_ERROR { - fmt.Printf(format, v...) + logWithPrefix(fmt.Sprintf(format, v...)) } }