nocui works correctly

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-27 09:02:42 -06:00
parent 7371f0428f
commit 53f2462b32
1 changed files with 7 additions and 1 deletions

View File

@ -40,6 +40,7 @@ var ERROR *LogFlag // toggles log.Warn() (true by default)
var PRINTLN *LogFlag // toggles log.Println() (true by default)
var always *LogFlag
var allon bool = false
// writeMutex protects locks the write process
var flagsMutex sync.Mutex
@ -103,6 +104,7 @@ func (f *LogFlag) Ok() bool {
func SetAll(b bool) {
flagsMutex.Lock()
defer flagsMutex.Unlock()
allon = b
for _, f := range flags {
f.b = b
}
@ -187,7 +189,11 @@ func NewFlag(name string, b bool, full, short, desc string) *LogFlag {
defer flagsMutex.Unlock()
f := new(LogFlag)
Log(always, "log.SetFlag() ", full, short, name, true)
if allon {
f.b = true
} else {
f.b = b
}
f.orig = b
f.short = short
f.subsystem = full