use log Flags

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 20:29:57 -06:00
parent 85cbd78883
commit 30832551c3
8 changed files with 38 additions and 20 deletions

18
args.go Normal file
View File

@ -0,0 +1,18 @@
package gadgets
// initializes logging and command line options
import (
"go.wit.com/log"
)
var INFO log.LogFlag
func init() {
INFO.B = false
INFO.Name = "INFO"
INFO.Subsystem = "gadgets"
INFO.Short = "gadgets"
INFO.Desc = "general info"
INFO.Register()
}

View File

@ -43,14 +43,14 @@ func (d *BasicCombobox) Ready() bool {
func (d *BasicCombobox) Add(value string) {
if ! d.Ready() {return}
log.Println("BasicCombobox.Add() =", value)
log.Log(INFO, "BasicCombobox.Add() =", value)
d.d.AddDropdownName(value)
return
}
func (d *BasicCombobox) Set(value string) bool {
if ! d.Ready() {return false}
log.Println("BasicCombobox.Set() =", value)
log.Log(INFO, "BasicCombobox.Set() =", value)
d.d.SetText(value)
d.value = value
return true
@ -68,7 +68,7 @@ func NewBasicCombobox(p *gui.Node, name string) *BasicCombobox {
d.d = p.NewCombobox("")
d.d.Custom = func() {
d.value = d.Get()
log.Println("BasicCombobox.Custom() user changed value to =", d.value)
log.Log(INFO, "BasicCombobox.Custom() user changed value to =", d.value)
if d.Custom != nil {
d.Custom()
}

View File

@ -43,14 +43,14 @@ func (d *BasicDropdown) Ready() bool {
func (d *BasicDropdown) Add(value string) {
if ! d.Ready() {return}
log.Println("BasicDropdown.Set() =", value)
log.Log(INFO, "BasicDropdown.Set() =", value)
d.d.AddDropdownName(value)
return
}
func (d *BasicDropdown) Set(value string) bool {
if ! d.Ready() {return false}
log.Println("BasicDropdown.Set() =", value)
log.Log(INFO, "BasicDropdown.Set() =", value)
d.l.SetText(value)
d.value = value
return true
@ -68,7 +68,7 @@ func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
d.d = p.NewDropdown("")
d.d.Custom = func() {
d.value = d.Get()
log.Println("BasicDropdown.Custom() user changed value to =", d.value)
log.Log(INFO, "BasicDropdown.Custom() user changed value to =", d.value)
if d.Custom != nil {
d.Custom()
}

View File

@ -30,7 +30,7 @@ func (n *BasicEntry) Get() string {
}
func (n *BasicEntry) Set(value string) *BasicEntry {
log.Println("BasicEntry.Set() =", value)
log.Log(INFO, "BasicEntry.Set() =", value)
if (n.v != nil) {
n.v.Set(value)
}
@ -49,7 +49,7 @@ func NewBasicEntry(p *gui.Node, name string) *BasicEntry {
d.v = p.NewEntryLine("")
d.v.Custom = func() {
d.value = d.v.S
log.Println("BasicEntry.Custom() user changed value to =", d.value)
log.Log(INFO, "BasicEntry.Custom() user changed value to =", d.value)
}
return &d

View File

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

View File

@ -76,7 +76,7 @@ func (w *BasicWindow) Box() *gui.Node {
}
func (w *BasicWindow) Vertical() {
log.Warn("BasicWindow() w.vertical =", w.vertical)
log.Log(INFO, "BasicWindow() w.vertical =", w.vertical)
if ! w.Initialized() {
log.Warn("BasicWindow() not Initialized yet()")
return
@ -86,7 +86,7 @@ func (w *BasicWindow) Vertical() {
return
}
w.vertical = true
log.Warn("BasicWindow() w.vertical =", w.vertical)
log.Log(INFO, "BasicWindow() w.vertical =", w.vertical)
}
func (w *BasicWindow) Draw() {
@ -94,14 +94,14 @@ func (w *BasicWindow) Draw() {
// various timeout settings
w.win = w.parent.NewWindow(w.name)
w.win.Custom = func() {
log.Println("BasicWindow.Custom() closed. TODO: handle this", w.name)
log.Warn("BasicWindow.Custom() closed. TODO: handle this", w.name)
}
if w.vertical {
w.box = w.win.NewBox("bw vbox", false)
log.Warn("BasicWindow.Custom() made vbox")
log.Log(INFO, "BasicWindow.Custom() made vbox")
} else {
w.box = w.win.NewBox("bw hbox", true)
log.Warn("BasicWindow.Custom() made hbox")
log.Log(INFO, "BasicWindow.Custom() made hbox")
}
w.ready = true

View File

@ -5,10 +5,10 @@
package gadgets
import (
"log"
"fmt"
"time"
"go.wit.com/log"
"go.wit.com/gui/gui"
)
@ -42,13 +42,13 @@ func (n *Duration) Set(d time.Duration) {
timeRange = n.High - n.Low
step = timeRange / 1000
if (step == 0) {
log.Println("duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
n.s.Set(0)
return
}
offset = d - n.Low
i := int(offset / step)
log.Println("duration.Set() =", n.Low, n.High, d, "i =", i)
log.Log(INFO, "duration.Set() =", n.Low, n.High, d, "i =", i)
n.s.I = i
n.s.Set(i)
n.s.Custom()

View File

@ -30,7 +30,7 @@ func (n *OneLiner) Get() string {
}
func (n *OneLiner) Set(value string) *OneLiner {
log.Println("OneLiner.Set() =", value)
log.Log(INFO, "OneLiner.Set() =", value)
if (n.v != nil) {
n.v.Set(value)
}
@ -49,7 +49,7 @@ func NewOneLiner(n *gui.Node, name string) *OneLiner {
d.v = n.NewLabel("")
d.v.Custom = func() {
d.value = d.v.S
log.Println("OneLiner.Custom() user changed value to =", d.value)
log.Log(INFO, "OneLiner.Custom() user changed value to =", d.value)
}
return &d