mirror of
https://github.com/ghostersk/gowebmail.git
synced 2026-04-17 16:46:01 +01:00
25 lines
567 B
Go
25 lines
567 B
Go
|
|
// Package logger provides a conditional debug logger controlled by config.Debug.
|
||
|
|
package logger
|
||
|
|
|
||
|
|
import "log"
|
||
|
|
|
||
|
|
var debugEnabled bool
|
||
|
|
|
||
|
|
// Init sets whether debug logging is active. Call once at startup.
|
||
|
|
func Init(debug bool) {
|
||
|
|
debugEnabled = debug
|
||
|
|
if debug {
|
||
|
|
log.Println("[logger] debug logging enabled")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Debug logs a message only when debug mode is on.
|
||
|
|
func Debug(format string, args ...interface{}) {
|
||
|
|
if debugEnabled {
|
||
|
|
log.Printf(format, args...)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// IsEnabled returns true if debug logging is on.
|
||
|
|
func IsEnabled() bool { return debugEnabled }
|