trying to make this work again

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-20 13:42:42 -06:00
parent 67fcbe1f5d
commit fce5068f04
1 changed files with 21 additions and 32 deletions

View File

@ -93,7 +93,7 @@ func SetDefaults() {
}
}
// protects against panic() by making sure it exists.
// simply protects against panic() by making sure it exists.
func (f *LogFlag) Ok() bool {
if f == nil {return false}
return true
@ -139,6 +139,20 @@ func (f *LogFlag) Get() bool {
return f.b
}
/*
func (f *LogFlag) Set(b bool) {
if ! f.Ok() {}
f.b = b
}
*/
// probably a better name than Get()
// switch to this
func (f *LogFlag) Bool() bool {
if ! f.Ok() {return false}
return f.b
}
// returns the name of the flag
func (f *LogFlag) GetName() string {
if ! f.Ok() {return ""}
@ -157,6 +171,12 @@ func (f *LogFlag) GetDesc() string {
return f.desc
}
// returns the description of the flag
func (f *LogFlag) GetDefault() bool {
if ! f.Ok() {return false}
return f.orig
}
// register a variable name from a subsystem
// inspired by Alex Flint
// set the Default value at the time of registration
@ -185,34 +205,3 @@ func (f *LogFlag) Set(b bool) {
f.b = b
Info("Set() f.b is now", f.b)
}
/*
func Set(subsystem string, name string, b bool) {
flagsMutex.Lock()
defer flagsMutex.Unlock()
Verbose("log.Set() TODO find var:", "(" + subsystem + ")", name, "=", b)
for _, f := range flags {
Verbose("log.Set() ", "(" + f.subsystem + ")", f.name, "=", f.b, ":", f.desc)
if (subsystem == f.subsystem) && (name == f.name) {
Verbose("log.Set() FOUND ", f)
f.b = b
return
}
}
}
func Get(subsystem string, name string) bool {
flagsMutex.Lock()
defer flagsMutex.Unlock()
Verbose("log.Get() TODO find var:", "(" + subsystem + ")", name)
for _, f := range flags {
Verbose("log.Get() ", "(" + f.subsystem + ")", f.name, "=", f.b, ":", f.desc)
if (subsystem == f.subsystem) && (name == f.name) {
Verbose("log.Get() FOUND ", f)
return f.b
}
}
return false
}
*/