From 894f77b3ce9572b81e7f2c657feeee3bc901ae0c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 8 Jan 2024 22:33:55 -0600 Subject: [PATCH] go.wit.com/log change Signed-off-by: Jeff Carr --- Makefile | 3 +++ args.go | 10 ++++------ logFlag.go | 18 +++++++++--------- logsettings/draw.go | 22 ++++++++++++---------- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index c2a13b9..85e980f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/args.go b/args.go index 0c6e9e6..7a4a106 100644 --- a/args.go +++ b/args.go @@ -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") } diff --git a/logFlag.go b/logFlag.go index 1b871d4..3adcd26 100644 --- a/logFlag.go +++ b/logFlag.go @@ -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 } diff --git a/logsettings/draw.go b/logsettings/draw.go index 3261f23..9354ab9 100644 --- a/logsettings/draw.go +++ b/logsettings/draw.go @@ -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) }