2024-01-04 12:23:36 -06:00
|
|
|
/*
|
|
|
|
A log.Flag
|
|
|
|
|
|
|
|
-----------------------------------------------
|
|
|
|
| | |
|
|
|
|
| [ X ] | INFO (controls log.Info() |
|
|
|
|
| | |
|
|
|
|
-----------------------------------------------
|
|
|
|
*/
|
|
|
|
package gadgets
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/gui/gui"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LogFlag struct {
|
|
|
|
p *gui.Node // parent widget
|
|
|
|
c *gui.Node // checkbox widget
|
|
|
|
|
2024-01-04 14:41:37 -06:00
|
|
|
Name string
|
|
|
|
Subsystem string
|
|
|
|
Desc string
|
2024-01-04 12:23:36 -06:00
|
|
|
b bool
|
|
|
|
|
|
|
|
Custom func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *LogFlag) Get() bool {
|
2024-01-04 14:41:37 -06:00
|
|
|
return log.Get(f.Subsystem, f.Name)
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *LogFlag) Set(b bool) {
|
|
|
|
log.Println("LogFlag.Set() =", b)
|
2024-01-04 14:41:37 -06:00
|
|
|
log.Set(f.Subsystem, f.Name, b)
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
|
|
|
|
f := LogFlag {
|
2024-01-04 14:41:37 -06:00
|
|
|
Name: lf.Name,
|
|
|
|
Subsystem: lf.Subsystem,
|
|
|
|
Desc: lf.Desc,
|
2024-01-04 12:23:36 -06:00
|
|
|
p: n,
|
|
|
|
}
|
|
|
|
|
|
|
|
// various timeout settings
|
2024-01-04 14:41:37 -06:00
|
|
|
f.c = n.NewCheckbox(f.Name + ": " + f.Desc)
|
2024-01-04 12:23:36 -06:00
|
|
|
f.c.Custom = func() {
|
2024-01-04 14:41:37 -06:00
|
|
|
log.Set(f.Subsystem, f.Name, f.c.B)
|
|
|
|
log.Println("LogFlag.Custom() user changed value to =", log.Get(f.Subsystem, f.Name))
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &f
|
|
|
|
}
|