This removes the requirement to call fmsg.Exit on every exit path, and enables direct use of the "log" package. However, fmsg.BeforeExit is still encouraged when possible to catch exit on suspended output. Signed-off-by: Ophestra <cat@gensokyo.uk>
24 lines
332 B
Go
24 lines
332 B
Go
package fmsg
|
|
|
|
import (
|
|
"log"
|
|
"sync/atomic"
|
|
)
|
|
|
|
var verbose = new(atomic.Bool)
|
|
|
|
func Load() bool { return verbose.Load() }
|
|
func Store(v bool) { verbose.Store(v) }
|
|
|
|
func Verbosef(format string, v ...any) {
|
|
if verbose.Load() {
|
|
log.Printf(format, v...)
|
|
}
|
|
}
|
|
|
|
func Verbose(v ...any) {
|
|
if verbose.Load() {
|
|
log.Println(v...)
|
|
}
|
|
}
|