go.wit.com/log change

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-08 22:33:55 -06:00
parent 366dc54ae4
commit 894f77b3ce
4 changed files with 28 additions and 25 deletions

View File

@ -23,3 +23,6 @@ github:
git push github master
git push github devel
git push github --tags
goproxy:
GOPROXY=https://proxy.golang.org GO111MODULE=on go get go.wit.com/gui/gadgets@v0.10

10
args.go
View File

@ -9,10 +9,8 @@ import (
var INFO log.LogFlag
func init() {
INFO.B = false
INFO.Name = "INFO"
INFO.Subsystem = "gadgets"
INFO.Short = "gadgets"
INFO.Desc = "general info"
INFO.Register()
full := "go.wit.com/gui/gadget"
short := "gadgets"
INFO.NewFlag("INFO", false, full, short, "General Info")
}

View File

@ -17,6 +17,7 @@ import (
type LogFlag struct {
p *gui.Node // parent widget
c *gui.Node // checkbox widget
lf *log.LogFlag
Name string
Subsystem string
@ -28,29 +29,28 @@ type LogFlag struct {
}
func (f *LogFlag) Get() bool {
return log.Get(f.Subsystem, f.Name)
return f.lf.Get()
}
func (f *LogFlag) Set(b bool) {
log.Info("LogFlag.Set() =", b)
log.Set(f.Subsystem, f.Name, b)
f.lf.Set(b)
f.c.Set(b)
}
func (f *LogFlag) SetDefault() {
log.Info("LogFlag.SetDefault() =", f.Default)
log.Set(f.Subsystem, f.Name, f.Default)
f.c.Set(f.Default)
f.lf.SetDefault()
f.c.Set(f.lf.Get())
}
func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
f := LogFlag {
Name: lf.Name,
Subsystem: lf.Subsystem,
Desc: lf.Desc,
Default: lf.Default,
p: n,
}
f.Name = lf.GetName()
f.Subsystem = lf.GetSubsystem()
f.Desc = lf.GetDesc()
// various timeout settings
f.c = n.NewCheckbox(f.Name + ": " + f.Desc)
@ -58,7 +58,7 @@ func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
log.Set(f.Subsystem, f.Name, f.c.B)
log.Info("LogFlag.Custom() user changed value to =", log.Get(f.Subsystem, f.Name))
}
f.c.Set(lf.B)
f.c.Set(lf.Get())
return &f
}

View File

@ -63,9 +63,9 @@ func (d *LogSettings) draw() {
// ShowDebugValues()
log.ShowFlags()
for s, wg := range myLogGui.groups {
log.Log(true, "Dump Flags", s)
log.Info("Dump Flags", s)
for _, f := range wg.flags {
log.Log(true, "Dump Flags\t", f.Get(), f.Name, ":", f.Desc)
log.Info("Dump Flags\t", f.Get(), f.Name, ":", f.Desc)
}
}
})
@ -85,7 +85,6 @@ func (d *LogSettings) draw() {
flags := log.ShowFlags()
for _, f := range flags {
log.Log(true, "Get() ", "(" + f.Subsystem + ")", f.Name, "=", f.B, ":", f.Desc)
addFlag(d.flagG, f)
}
}
@ -95,24 +94,27 @@ func addFlag(p *gui.Node, newf *log.LogFlag) {
if newf == nil { return }
if p == nil { return }
if myLogGui.groups[newf.Subsystem] == nil {
subsys := newf.GetSubsystem()
name := newf.GetName()
if myLogGui.groups[subsys] == nil {
flagWidgets = new(flagGroup)
flagWidgets.parent = p
flagWidgets.name = newf.Subsystem
flagWidgets.group = p.NewGroup(newf.Subsystem)
flagWidgets.name = subsys
flagWidgets.group = p.NewGroup(subsys)
flagWidgets.grid = flagWidgets.group.NewGrid("flags grid", 3, 1)
myLogGui.groups[newf.Subsystem] = flagWidgets
myLogGui.groups[subsys] = flagWidgets
} else {
flagWidgets = myLogGui.groups[newf.Subsystem]
flagWidgets = myLogGui.groups[subsys]
}
for _, f := range flagWidgets.flags {
if f.Name == newf.Name {
if f.Name == name {
log.Info("addFlag() FOUND FLAG", f)
return
}
}
log.Info("addFlag() Adding new flag:", newf.Subsystem, newf.Name)
log.Info("addFlag() Adding new flag:", subsys, name)
newWidget := gadgets.NewLogFlag(flagWidgets.grid, newf)
flagWidgets.flags = append(flagWidgets.flags, newWidget)
}