trying to make this work again
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
67fcbe1f5d
commit
fce5068f04
53
flags.go
53
flags.go
|
@ -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 {
|
func (f *LogFlag) Ok() bool {
|
||||||
if f == nil {return false}
|
if f == nil {return false}
|
||||||
return true
|
return true
|
||||||
|
@ -139,6 +139,20 @@ func (f *LogFlag) Get() bool {
|
||||||
return f.b
|
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
|
// returns the name of the flag
|
||||||
func (f *LogFlag) GetName() string {
|
func (f *LogFlag) GetName() string {
|
||||||
if ! f.Ok() {return ""}
|
if ! f.Ok() {return ""}
|
||||||
|
@ -157,6 +171,12 @@ func (f *LogFlag) GetDesc() string {
|
||||||
return f.desc
|
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
|
// register a variable name from a subsystem
|
||||||
// inspired by Alex Flint
|
// inspired by Alex Flint
|
||||||
// set the Default value at the time of registration
|
// set the Default value at the time of registration
|
||||||
|
@ -185,34 +205,3 @@ func (f *LogFlag) Set(b bool) {
|
||||||
f.b = b
|
f.b = b
|
||||||
Info("Set() f.b is now", f.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
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in New Issue