feat: prepend log messages with prefix
This commit is contained in:
parent
2f58916cba
commit
6aac24d118
@ -15,12 +15,16 @@ func SetLoglevel(_loglevel int) {
|
|||||||
loglevel = _loglevel
|
loglevel = _loglevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func logWithPrefix(message string) {
|
||||||
|
fmt.Printf("knowyt: %s", message)
|
||||||
|
}
|
||||||
|
|
||||||
func Debug(format string, v ...any) {
|
func Debug(format string, v ...any) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
|
|
||||||
if loglevel >= LOG_DEBUG {
|
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()
|
defer lock.Unlock()
|
||||||
|
|
||||||
if loglevel >= LOG_INFO {
|
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()
|
defer lock.Unlock()
|
||||||
|
|
||||||
if loglevel >= LOG_WARN {
|
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()
|
defer lock.Unlock()
|
||||||
|
|
||||||
if loglevel >= LOG_ERROR {
|
if loglevel >= LOG_ERROR {
|
||||||
fmt.Printf(format, v...)
|
logWithPrefix(fmt.Sprintf(format, v...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user