44 lines
639 B
Go
44 lines
639 B
Go
|
package log
|
||
|
|
||
|
// implements 'daemon' mode so switches to fmt
|
||
|
// instead of log so that timestamps are not printed twice
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
reallog "log"
|
||
|
)
|
||
|
|
||
|
var daemonMode bool = false
|
||
|
|
||
|
func DaemonMode(b bool) {
|
||
|
daemonMode = b
|
||
|
}
|
||
|
|
||
|
func realPrintln(a ...any) {
|
||
|
if daemonMode {
|
||
|
fmt.Println(a...)
|
||
|
} else {
|
||
|
reallog.Println(a...)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func realPrintf(s string, a ...any) {
|
||
|
if daemonMode {
|
||
|
fmt.Printf(s, a...)
|
||
|
} else {
|
||
|
reallog.Printf(s, a...)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func realFatalln(a ...any) {
|
||
|
reallog.Fatalln(a...)
|
||
|
}
|
||
|
|
||
|
func realFatalf(s string, a ...any) {
|
||
|
reallog.Fatalf(s, a...)
|
||
|
}
|
||
|
|
||
|
func realFatal(s string, a ...any) {
|
||
|
reallog.Fatalf(s, a...)
|
||
|
}
|