diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2022-12-28 13:27:05 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2022-12-28 13:27:05 +0100 |
| commit | aa5c7fc159b0f5175ede96d46b8d2a2669a176a4 (patch) | |
| tree | 58964be878af574263b8d1994f3097860db2192e /llog/llog.go | |
| parent | e15e1c6a4cb4a534d649cfc3d1be68498fddac48 (diff) | |
| download | WRMS-aa5c7fc159b0f5175ede96d46b8d2a2669a176a4.tar.gz WRMS-aa5c7fc159b0f5175ede96d46b8d2a2669a176a4.zip | |
llog: use variable argument list
Mirror more closely the fmt interface and reduce the verbosity
of the log call sites.
Additionally the log message is only created if we are actually going
to log it.
Diffstat (limited to 'llog/llog.go')
| -rw-r--r-- | llog/llog.go | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/llog/llog.go b/llog/llog.go index 3c05012..f7a5486 100644 --- a/llog/llog.go +++ b/llog/llog.go @@ -44,38 +44,41 @@ func (l LogLevel) String() string { return getLevelNames()[l-1] } -func Log(l LogLevel, msg string) { +func Log(l LogLevel, format string, a ...any) { + if l > Level { + return + } + + msg := fmt.Sprintf(format, a...) msg = fmt.Sprintf("[%s] %s", l.String(), msg) if l == l_Fatal { log.Fatalln(msg) - } - - if l <= Level { + } else { log.Println(msg) } } -func Fatal(msg string) { - Log(l_Fatal, msg) +func Fatal(format string, a ...any) { + Log(l_Fatal, format, a...) } -func Error(msg string) { - Log(l_Error, msg) +func Error(format string, a ...any) { + Log(l_Error, format, a...) } -func Warning(msg string) { - Log(l_Warning, msg) +func Warning(format string, a ...any) { + Log(l_Warning, format, a...) } -func Info(msg string) { - Log(l_Info, msg) +func Info(format string, a ...any) { + Log(l_Info, format, a...) } -func Debug(msg string) { - Log(l_Debug, msg) +func Debug(format string, a ...any) { + Log(l_Debug, format, a...) } -func DDebug(msg string) { - Log(l_DDebug, msg) +func DDebug(format string, a ...any) { + Log(l_DDebug, format, a...) } |
