loggging output cleanups

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-21 11:42:31 -06:00
parent 50074e543b
commit 5eea7f5059
11 changed files with 45 additions and 62 deletions

View File

@ -6,11 +6,11 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
var INFO *log.LogFlag var GADGETS *log.LogFlag
func init() { func init() {
full := "go.wit.com/gui/gadget" full := "go.wit.com/gui"
short := "gadgets" short := "gadgets"
INFO = log.NewFlag("INFO", false, full, short, "General Info") GADGETS = log.NewFlag("GADGETS", false, full, short, "General Info")
} }

View File

@ -82,7 +82,7 @@ func (d *BasicCombobox) AddText(s string) {
if !d.Ready() { if !d.Ready() {
return return
} }
log.Log(INFO, "BasicCombobox.Add() =", s) log.Log(GADGETS, "BasicCombobox.Add() =", s)
d.d.AddText(s) d.d.AddText(s)
} }
@ -96,7 +96,7 @@ func NewBasicCombobox(p *gui.Node, label string) *BasicCombobox {
d.l = p.NewLabel(label) d.l = p.NewLabel(label)
d.d = p.NewCombobox() d.d = p.NewCombobox()
d.d.Custom = func() { d.d.Custom = func() {
log.Warn("BasicCombobox.Custom() user changed value to =", d.String()) log.Log(GADGETS, "BasicCombobox.Custom() user changed value to =", d.String())
if d.Custom != nil { if d.Custom != nil {
d.Custom() d.Custom()
} }

View File

@ -49,7 +49,7 @@ func (d *BasicDropdown) AddText(s string) {
if !d.Ready() { if !d.Ready() {
return return
} }
log.Log(INFO, "BasicDropdown.AddText() =", s) log.Log(GADGETS, "BasicDropdown.AddText() =", s)
d.d.AddText(s) d.d.AddText(s)
return return
} }
@ -58,7 +58,7 @@ func (d *BasicDropdown) SetText(s string) {
if !d.Ready() { if !d.Ready() {
return return
} }
log.Log(INFO, "BasicDropdown.SetText() =", s) log.Log(GADGETS, "BasicDropdown.SetText() =", s)
d.d.SetText(s) d.d.SetText(s)
return return
} }
@ -67,7 +67,7 @@ func (d *BasicDropdown) String() string {
if !d.Ready() { if !d.Ready() {
return "" return ""
} }
log.Log(INFO, "BasicDropdown.String()", d.d.String()) log.Log(GADGETS, "BasicDropdown.String()", d.d.String())
return d.d.String() return d.d.String()
} }
@ -75,7 +75,7 @@ func (d *BasicDropdown) SetLabel(value string) bool {
if !d.Ready() { if !d.Ready() {
return false return false
} }
log.Log(INFO, "BasicDropdown.SetLabel() =", value) log.Log(GADGETS, "BasicDropdown.SetLabel() =", value)
d.l.SetText(value) d.l.SetText(value)
return true return true
} }
@ -83,7 +83,7 @@ func (d *BasicDropdown) SetLabel(value string) bool {
/* /*
func (d *BasicDropdown) Set(value string) bool { func (d *BasicDropdown) Set(value string) bool {
if ! d.Ready() {return false} if ! d.Ready() {return false}
log.Log(INFO, "BasicDropdown.Set() =", value) log.Log(GADGETS, "BasicDropdown.Set() =", value)
d.d.SetText(value) d.d.SetText(value)
d.value = value d.value = value
return true return true
@ -102,7 +102,7 @@ func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
d.d = p.NewDropdown() d.d = p.NewDropdown()
d.d.Custom = func() { d.d.Custom = func() {
d.value = d.d.String() d.value = d.d.String()
log.Log(INFO, "BasicDropdown.Custom() user changed value to =", d.value) log.Log(GADGETS, "BasicDropdown.Custom() user changed value to =", d.value)
if d.Custom != nil { if d.Custom != nil {
d.Custom() d.Custom()
} }

View File

@ -23,23 +23,23 @@ type BasicEntry struct {
} }
func (n *BasicEntry) SetText(s string) *BasicEntry { func (n *BasicEntry) SetText(s string) *BasicEntry {
log.Log(INFO, "BasicEntry.Set() =", s) log.Log(GADGETS, "BasicEntry.Set() =", s)
n.v.SetText(s) n.v.SetText(s)
return n return n
} }
func (n *BasicEntry) Enable() { func (n *BasicEntry) Enable() {
log.Log(INFO, "BasicEntry.Enable()") log.Log(GADGETS, "BasicEntry.Enable()")
n.v.Enable() n.v.Enable()
} }
func (n *BasicEntry) Disable() { func (n *BasicEntry) Disable() {
log.Log(INFO, "BasicEntry.Disable()") log.Log(GADGETS, "BasicEntry.Disable()")
n.v.Disable() n.v.Disable()
} }
func (n *BasicEntry) String() string { func (n *BasicEntry) String() string {
log.Log(INFO, "BasicEntry.SetLabel() =", n.v.String()) log.Log(GADGETS, "BasicEntry.SetLabel() =", n.v.String())
return n.v.String() return n.v.String()
} }
@ -57,7 +57,7 @@ func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
d.l = p.NewLabel(name) d.l = p.NewLabel(name)
d.v = p.NewEntryLine("") d.v = p.NewEntryLine("")
d.v.Custom = func() { d.v.Custom = func() {
log.Log(INFO, "BasicEntry() user changed =", d.String()) log.Log(GADGETS, "BasicEntry() user changed =", d.String())
if d.Custom != nil { if d.Custom != nil {
d.Custom() d.Custom()
} }

View File

@ -33,7 +33,7 @@ func (n *BasicLabel) Get() string {
} }
func (n *BasicLabel) Set(value string) *BasicLabel { func (n *BasicLabel) Set(value string) *BasicLabel {
log.Log(INFO, "BasicLabel.Set() =", value) log.Log(GADGETS, "BasicLabel.Set() =", value)
if (n.v != nil) { if (n.v != nil) {
n.v.Set(value) n.v.Set(value)
} }
@ -55,7 +55,7 @@ func (ngui *Node) NewBasicLabel(name string) *BasicLabel {
d.v = n.NewLabel("") d.v = n.NewLabel("")
d.v.Custom = func() { d.v.Custom = func() {
d.value = d.v.String() d.value = d.v.String()
log.Log(INFO, "BasicLabel.Custom() user changed value to =", d.value) log.Log(GADGETS, "BasicLabel.Custom() user changed value to =", d.value)
} }
return &d return &d

View File

@ -28,7 +28,7 @@ func NewBasicWindow(parent *gui.Node, title string) *BasicWindow {
title: title, title: title,
vertical: false, vertical: false,
} }
log.Warn("NewBasicWindow() END") log.Log(GADGETS, "NewBasicWindow() END")
return w return w
} }
@ -46,7 +46,7 @@ func (w *BasicWindow) Hide() {
if !w.Ready() { if !w.Ready() {
return return
} }
log.Warn("BasicWindow.Hide() here") log.Log(GADGETS, "BasicWindow.Hide() here")
w.win.Hide() w.win.Hide()
w.hidden = true w.hidden = true
return return
@ -93,17 +93,6 @@ func (w *BasicWindow) StandardClose() {
return return
} }
w.win.Custom = w.win.StandardClose w.win.Custom = w.win.StandardClose
/*
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title)
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
if w.Custom != nil {
log.Warn("BasicWindow.Custom() HAS CUSTOM")
w.Custom()
return
}
w.win.StandardExit()
}
*/
return return
} }
@ -113,10 +102,9 @@ func (w *BasicWindow) StandardExit() {
return return
} }
w.win.Custom = func() { w.win.Custom = func() {
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title) log.Log(GADGETS, "BasicWindow.Custom() closed. handled properly?", w.title)
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
if w.Custom != nil { if w.Custom != nil {
log.Warn("BasicWindow.Custom() HAS CUSTOM") log.Log(GADGETS, "BasicWindow.Custom() HAS CUSTOM")
w.Custom() w.Custom()
return return
} }
@ -155,26 +143,26 @@ func (w *BasicWindow) Box() *gui.Node {
} }
func (w *BasicWindow) Vertical() { func (w *BasicWindow) Vertical() {
log.Warn("BasicWindow() Vertical() START w.vertical =", w.vertical, w.title) log.Log(GADGETS, "BasicWindow() Vertical() START w.vertical =", w.vertical, w.title)
if w == nil { if w == nil {
return return
} }
w.vertical = true w.vertical = true
log.Warn("BasicWindow() Vertical() END w.vertical =", w.vertical, w.title) log.Log(GADGETS, "BasicWindow() Vertical() END w.vertical =", w.vertical, w.title)
} }
func (w *BasicWindow) Horizontal() { func (w *BasicWindow) Horizontal() {
log.Warn("BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title) log.Log(GADGETS, "BasicWindow() Horizontal() START w.vertical =", w.vertical, w.title)
if w == nil { if w == nil {
return return
} }
w.vertical = false w.vertical = false
log.Warn("BasicWindow() Horizontal() END w.vertical =", w.vertical, w.title) log.Log(GADGETS, "BasicWindow() Horizontal() END w.vertical =", w.vertical, w.title)
} }
func (w *BasicWindow) Make() { func (w *BasicWindow) Make() {
if w.win != nil { if w.win != nil {
log.Warn("BasicWindow.Make() window was already created") log.Log(GADGETS, "BasicWindow.Make() window was already created")
return return
} }
w.win = w.parent.RawWindow(w.title) w.win = w.parent.RawWindow(w.title)
@ -185,8 +173,7 @@ func (w *BasicWindow) Make() {
// I like to call this Sierpinski mode // I like to call this Sierpinski mode
if w.win.Custom == nil { if w.win.Custom == nil {
w.win.Custom = func() { w.win.Custom = func() {
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.title) log.Log(GADGETS, "BasicWindow.Custom() closed. handled properly?", w.title)
log.Warn("BasicWindow.Custom() closed. handled properly?", w.title)
if w.Custom != nil { if w.Custom != nil {
w.Custom() w.Custom()
} }
@ -194,10 +181,10 @@ func (w *BasicWindow) Make() {
} }
if w.vertical { if w.vertical {
w.box = w.win.NewVerticalBox("BW VBOX") w.box = w.win.NewVerticalBox("BW VBOX")
log.Log(INFO, "BasicWindow.Make() made NewVerticalBox", w.title) log.Log(GADGETS, "BasicWindow.Make() made NewVerticalBox", w.title)
} else { } else {
w.box = w.win.NewHorizontalBox("BW HBOX") w.box = w.win.NewHorizontalBox("BW HBOX")
log.Log(INFO, "BasicWindow.Make() made NewHorizontalBox", w.title) log.Log(GADGETS, "BasicWindow.Make() made NewHorizontalBox", w.title)
} }
w.win.SetVisable(false) w.win.SetVisable(false)
@ -209,16 +196,16 @@ func (w *BasicWindow) TestDraw() {
return return
} }
if w.win == nil { if w.win == nil {
log.Warn("BasicWindow.TestDraw() can't draw on window == nil") log.Log(GADGETS, "BasicWindow.TestDraw() can't draw on window == nil")
w.Make() w.Make()
} }
log.Warn("BasicWindow.TestDraw() RUNNING HERE") log.Log(GADGETS, "BasicWindow.TestDraw() RUNNING HERE")
w.win.TestDraw() w.win.TestDraw()
} }
func (w *BasicWindow) Draw() { func (w *BasicWindow) Draw() {
if w.win == nil { if w.win == nil {
log.Warn("BasicWindow.Draw() needs Make()") log.Log(GADGETS, "BasicWindow.Draw() needs Make()")
w.Make() w.Make()
} }
w.win.TestDraw() w.win.TestDraw()

View File

@ -42,13 +42,13 @@ func (n *Duration) Set(d time.Duration) {
timeRange = n.High - n.Low timeRange = n.High - n.Low
step = timeRange / 1000 step = timeRange / 1000
if step == 0 { if step == 0 {
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step) log.Log(GADGETS, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
n.s.SetValue(0) n.s.SetValue(0)
return return
} }
offset = d - n.Low offset = d - n.Low
i := int(offset / step) i := int(offset / step)
log.Log(INFO, "duration.Set() =", n.Low, n.High, d, "i =", i) log.Log(GADGETS, "duration.Set() =", n.Low, n.High, d, "i =", i)
// n.s.I = i // n.s.I = i
n.s.SetValue(i) n.s.SetValue(i)
n.s.Custom() n.s.Custom()

2
go.mod
View File

@ -3,7 +3,7 @@ module go.wit.com/lib/gadgets
go 1.21.4 go 1.21.4
require ( require (
go.wit.com/gui v0.12.19 go.wit.com/gui v0.12.20
go.wit.com/log v0.5.6 go.wit.com/log v0.5.6
) )

8
go.sum
View File

@ -4,13 +4,9 @@ go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/gui v0.12.18 h1:gFVDaJFz/Su8JgUd9Oxnb3t+FS+bzy5WJSvGoKVGYZU= go.wit.com/gui v0.12.20 h1:mIc2DKGcpQjZdgtAj5qzkBrBDiteWfIaEpLyMnIBkh8=
go.wit.com/gui v0.12.18/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto= go.wit.com/gui v0.12.20/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
go.wit.com/gui v0.12.19 h1:OEnsnZnec7Q2jZVjwl413V0wuVAAB4r2mGTY0IouBuw=
go.wit.com/gui v0.12.19/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30=
go.wit.com/widget v1.1.5/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=
go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY= go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY=
go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=

View File

@ -57,10 +57,10 @@ func (f *LogFlag) GetDesc() string {
} }
func (f *LogFlag) SetValue(b bool) { func (f *LogFlag) SetValue(b bool) {
log.Info("LogFlag.SetValue() before SetValue() log.flag =", f.lf.Bool(), "checkbox =", f.checkbox.Bool()) log.Log(GADGETS, "LogFlag.SetValue() before SetValue() log.flag =", f.lf.Bool(), "checkbox =", f.checkbox.Bool())
f.checkbox.SetChecked(b) f.checkbox.SetChecked(b)
f.lf.SetBool(b) f.lf.SetBool(b)
log.Info("LogFlag.SetValue() after SetValue() log.flag =", f.lf.Bool(), "checkbox =", f.checkbox.Bool()) log.Log(GADGETS, "LogFlag.SetValue() after SetValue() log.flag =", f.lf.Bool(), "checkbox =", f.checkbox.Bool())
} }
// should be RestoreDefault() ? // should be RestoreDefault() ?

View File

@ -27,24 +27,24 @@ func (n *OneLiner) String() string {
} }
func (n *OneLiner) SetValue(s string) *OneLiner { func (n *OneLiner) SetValue(s string) *OneLiner {
log.Warn("OneLiner.Set() =", s) log.Log(GADGETS, "OneLiner.Set() =", s)
n.v.SetLabel(s) n.v.SetLabel(s)
return n return n
} }
func (n *OneLiner) SetLabel(value string) *OneLiner { func (n *OneLiner) SetLabel(value string) *OneLiner {
log.Log(INFO, "OneLiner.SetLabel() =", value) log.Log(GADGETS, "OneLiner.SetLabel() =", value)
n.l.SetLabel(value) n.l.SetLabel(value)
return n return n
} }
func (n *OneLiner) Enable() { func (n *OneLiner) Enable() {
log.Log(INFO, "OneLiner.Enable()") log.Log(GADGETS, "OneLiner.Enable()")
n.v.Show() n.v.Show()
} }
func (n *OneLiner) Disable() { func (n *OneLiner) Disable() {
log.Log(INFO, "OneLiner.Disable()") log.Log(GADGETS, "OneLiner.Disable()")
n.v.Hide() n.v.Hide()
} }
@ -57,7 +57,7 @@ func NewOneLiner(n *gui.Node, label string) *OneLiner {
d.l = n.NewLabel(label) d.l = n.NewLabel(label)
d.v = n.NewLabel("") d.v = n.NewLabel("")
d.v.Custom = func() { d.v.Custom = func() {
log.Log(INFO, "OneLiner.Custom() user changed value to =", d.v.String()) log.Log(GADGETS, "OneLiner.Custom() user changed value to =", d.v.String())
} }
return &d return &d