diff options
| author | Jeff Carr <[email protected]> | 2024-10-12 16:21:47 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-12 16:21:47 -0500 |
| commit | 2cf02ee2e5f155205b847805b1bdccb42fcfec00 (patch) | |
| tree | 56317c3f2d3c8b5f2a69a442e74d7456a2df40b0 /reallog.go | |
| parent | 54c0947452516833f907fb78fce0532d39c84287 (diff) | |
half working 'daemon mode'
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'reallog.go')
| -rw-r--r-- | reallog.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/reallog.go b/reallog.go new file mode 100644 index 0000000..ec68547 --- /dev/null +++ b/reallog.go @@ -0,0 +1,43 @@ +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...) +} |
