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:18 -06:00
parent e2e4726ef7
commit 2b87ba4eaa
5 changed files with 37 additions and 39 deletions

20
args.go
View File

@ -9,7 +9,9 @@ import (
var INFO log.LogFlag var INFO log.LogFlag
var POLL log.LogFlag var POLL log.LogFlag
var BUG log.LogFlag var CHAN log.LogFlag
var WARN log.LogFlag
var argDebugger ArgsDebugger var argDebugger ArgsDebugger
// This struct can be used with the go-arg package // This struct can be used with the go-arg package
@ -25,15 +27,11 @@ func ArgDebug() bool {
func init() { func init() {
arg.Register(&argDebugger) arg.Register(&argDebugger)
INFO.B = false full := "go.wit.com/gui/debugger"
INFO.Name = "INFO" short := "bugger"
INFO.Subsystem = "bugger"
INFO.Desc = "simple debugging Info()"
INFO.Register()
POLL.B = false INFO.NewFlag("INFO", false, full, short, "simple debugging Info()")
POLL.Name = "POLL" POLL.NewFlag("POLL", false, full, short, "watch the debugger poll things")
POLL.Subsystem = "bugger" CHAN.NewFlag("CHAN", true, full, short, "chan() test code output")
POLL.Desc = "watch the debugger poll things" WARN.NewFlag("WARN", true, full, short, "should warn the user")
POLL.Register()
} }

View File

@ -26,10 +26,10 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow {
// var debugWG sync.WaitGroup // var debugWG sync.WaitGroup
g.NewButton("init()", func () { g.NewButton("init()", func () {
if (debugNumberChan == nil) { if (debugNumberChan == nil) {
log.Log(true, "making debugNumberChan channel") log.Log(CHAN, "making debugNumberChan channel")
debugNumberChan = make(chan int) debugNumberChan = make(chan int)
} else { } else {
log.Log(true, "debugNumberChan already made") log.Log(CHAN, "debugNumberChan already made")
} }
debugWG = new(sync.WaitGroup) debugWG = new(sync.WaitGroup)
}) })
@ -50,34 +50,34 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow {
go sendNumber(7) go sendNumber(7)
}) })
g.NewButton("send 4 numbers (chan <- int)", func () { g.NewButton("send 4 numbers (chan <- int)", func () {
log.Log(true, "generateNumbers(4)") log.Log(CHAN, "generateNumbers(4)")
go generateNumbers(4) go generateNumbers(4)
}) })
g.NewButton("debugWG.Done()", func () { g.NewButton("debugWG.Done()", func () {
log.Log(true, "ran debugWG.Done()") log.Log(CHAN, "ran debugWG.Done()")
debugWG.Done() debugWG.Done()
}) })
g.NewButton("close chan", func () { g.NewButton("close chan", func () {
log.Log(true, "close() on", debugNumberChan) log.Log(CHAN, "close() on", debugNumberChan)
close(debugNumberChan) close(debugNumberChan)
}) })
g.NewButton("print", func () { g.NewButton("print", func () {
log.Log(true, "waitgroup counter is ?") log.Log(CHAN, "waitgroup counter is ?")
}) })
return w return w
} }
func sendNumber(i int) { func sendNumber(i int) {
log.Log(true, "START debugNumberChan <-", i, " (sending", i, "to channel)") log.Log(CHAN, "START debugNumberChan <-", i, " (sending", i, "to channel)")
debugNumberChan <- i debugNumberChan <- i
debugWG.Wait() debugWG.Wait()
log.Log(true, "END debugNumberChan sendNumber() done", i) log.Log(CHAN, "END debugNumberChan sendNumber() done", i)
} }
func generateNumbers(total int) { func generateNumbers(total int) {
fmt.Printf("START generateNumbers()\n") fmt.Printf("START generateNumbers()\n")
for idx := 1; idx <= total; idx++ { for idx := 1; idx <= total; idx++ {
log.Log(true, "ran debugNumberChan <= idx where idx =", idx) log.Log(CHAN, "ran debugNumberChan <= idx where idx =", idx)
fmt.Printf("S generateNumbers() sending %d to channel\n", idx) fmt.Printf("S generateNumbers() sending %d to channel\n", idx)
debugNumberChan <- idx debugNumberChan <- idx
// res, err := (<-r)() // res, err := (<-r)()
@ -90,9 +90,9 @@ func generateNumbers(total int) {
// i equals the number of times to read values from the channel // i equals the number of times to read values from the channel
func printInt(i int, name string) { func printInt(i int, name string) {
tmp := 1 tmp := 1
log.Log(true, "START printInt", name, "read debugNumberChan()") log.Log(CHAN, "START printInt", name, "read debugNumberChan()")
for num := range debugNumberChan { for num := range debugNumberChan {
log.Log(true, "printInt()",name, "read", num, "from channel") log.Log(CHAN, "printInt()",name, "read", num, "from channel")
debugWG.Done() debugWG.Done()
if (tmp == i) { if (tmp == i) {
return return

View File

@ -73,7 +73,7 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
var tmp debug.GCStats var tmp debug.GCStats
var out string var out string
debug.ReadGCStats(&tmp) debug.ReadGCStats(&tmp)
log.Log(true, tmp) log.Log(INFO, tmp)
out += fmt.Sprintln("LastGC:", tmp.LastGC, "// time.Time time of last collection") out += fmt.Sprintln("LastGC:", tmp.LastGC, "// time.Time time of last collection")
out += fmt.Sprintln("NumGC:", tmp.NumGC, "// number of garbage collections") out += fmt.Sprintln("NumGC:", tmp.NumGC, "// number of garbage collections")
out += fmt.Sprintln("PauseTotal:", tmp.PauseTotal, "// total pause for all collections") out += fmt.Sprintln("PauseTotal:", tmp.PauseTotal, "// total pause for all collections")
@ -125,7 +125,7 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
og = w.Box().NewGroup("output").Pad() og = w.Box().NewGroup("output").Pad()
outputTextbox = og.NewTextbox("outputBox") outputTextbox = og.NewTextbox("outputBox")
outputTextbox.Custom = func () { outputTextbox.Custom = func () {
log.Log(true, "custom TextBox() for golang output a =", outputTextbox.S) log.Log(INFO, "custom TextBox() for golang output a =", outputTextbox.S)
} }
return w return w

View File

@ -81,12 +81,12 @@ func DebugWindow2(newB *gui.Node, title string) *gui.Node {
}) })
gr.NewButton("test conc", func () { gr.NewButton("test conc", func () {
log.Log(true, "TODO: fix me") log.Log(WARN, "TODO: fix me")
// makeConc() // makeConc()
}) })
gr.NewButton("List Plugins", func () { gr.NewButton("List Plugins", func () {
log.Log(true, "TODO: fix me") log.Log(WARN, "TODO: fix me")
/* /*
for _, aplug := range allPlugins { for _, aplug := range allPlugins {
log.Log(true, "Loaded plugin:", aplug.name, aplug.filename) log.Log(true, "Loaded plugin:", aplug.name, aplug.filename)
@ -137,7 +137,7 @@ func dropdownWindow(p *gui.Node) {
name := dd.S name := dd.S
activeWidget = mapWindows[name] activeWidget = mapWindows[name]
setActiveWidget(activeWidget) setActiveWidget(activeWidget)
log.Log(true, "The Window was set to", name) log.Log(INFO, "The Window was set to", name)
} }
log.Log(INFO, "dd =", dd) log.Log(INFO, "dd =", dd)
if (activeWidget == nil) { if (activeWidget == nil) {

View File

@ -140,7 +140,7 @@ func debugAddWidgetButtons(n *gui.Node) {
a.AddText("make something for tim for qflow") a.AddText("make something for tim for qflow")
a.AddText("and for riscv") a.AddText("and for riscv")
a.Custom = func () { a.Custom = func () {
log.Log(true, "custom dropdown() a =", a.Name, a.S) log.Log(WARN, "custom dropdown() a =", a.Name, a.S)
} }
}) })
n.NewButton("Combobox", func () { n.NewButton("Combobox", func () {
@ -148,7 +148,7 @@ func debugAddWidgetButtons(n *gui.Node) {
a.AddText("mirrors.wit.com") a.AddText("mirrors.wit.com")
a.AddText("go.wit.com") a.AddText("go.wit.com")
a.Custom = func () { a.Custom = func () {
log.Log(true, "custom combobox() a =", a.Name, a.S) log.Log(WARN, "custom combobox() a =", a.Name, a.S)
} }
}) })
n.NewButton("Grid", func () { n.NewButton("Grid", func () {
@ -222,13 +222,13 @@ func debugAddWidgetButton(n *gui.Node) {
activeWidget.SetNext(newX, newY) activeWidget.SetNext(newX, newY)
name = name + " (" + strconv.Itoa(newX) + "," + strconv.Itoa(newY) + ")" name = name + " (" + strconv.Itoa(newX) + "," + strconv.Itoa(newY) + ")"
} }
log.Log(true, "New Name =", name) log.Log(INFO, "New Name =", name)
log.Log(true, "New Type =", activeLabelNewType.S) log.Log(INFO, "New Type =", activeLabelNewType.S)
log.Log(true, "New X =", newX) log.Log(INFO, "New X =", newX)
log.Log(true, "New Y =", newY) log.Log(INFO, "New Y =", newY)
log.Log(true, "activeWidget.NextW =", activeWidget.NextW) log.Log(INFO, "activeWidget.NextW =", activeWidget.NextW)
log.Log(true, "activeWidget.NextH =", activeWidget.NextH) log.Log(INFO, "activeWidget.NextH =", activeWidget.NextH)
log.Log(true, "Add() size (X,Y)", activeWidget.X, activeWidget.Y, "put next thing at (W,H) =", activeWidget.NextW, activeWidget.NextH) log.Log(INFO, "Add() size (X,Y)", activeWidget.X, activeWidget.Y, "put next thing at (W,H) =", activeWidget.NextW, activeWidget.NextH)
activeWidget.Dump() activeWidget.Dump()
// activeWidget.X = newX // activeWidget.X = newX
@ -243,19 +243,19 @@ func debugAddWidgetButton(n *gui.Node) {
activeWidget.NewBox(name, newB) activeWidget.NewBox(name, newB)
case "Button": case "Button":
activeWidget.NewButton(name, func () { activeWidget.NewButton(name, func () {
log.Log(true, "got to button", name) log.Log(WARN, "got to button", name)
}) })
case "Checkbox": case "Checkbox":
a := activeWidget.NewCheckbox(name) a := activeWidget.NewCheckbox(name)
a.Custom = func () { a.Custom = func () {
log.Log(true, "custom checkox func a=", a.B) log.Log(WARN, "custom checkox func a=", a.B)
} }
case "Dropdown": case "Dropdown":
a := activeWidget.NewDropdown(name) a := activeWidget.NewDropdown(name)
a.AddText(name + " yay") a.AddText(name + " yay")
a.AddText(name + " haha") a.AddText(name + " haha")
a.Custom = func () { a.Custom = func () {
log.Log(true, "WTF a=", a.B) log.Log(WARN, "WTF a=", a.B)
} }
case "Combobox": case "Combobox":
a := activeWidget.NewCombobox(name) a := activeWidget.NewCombobox(name)