show/set flags from go.wit.com/log package
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
ff20e79426
commit
a7640472cb
104
debugFlags.go
104
debugFlags.go
|
@ -1,10 +1,51 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
newlog "go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogSettings struct {
|
||||||
|
ready bool
|
||||||
|
hidden bool
|
||||||
|
err error
|
||||||
|
name string
|
||||||
|
|
||||||
|
parent *Node // should be the root of the 'gui' package binary tree
|
||||||
|
window *Node // our window for displaying the log package settings
|
||||||
|
group *Node //
|
||||||
|
grid *Node //
|
||||||
|
checkbox *Node
|
||||||
|
label *Node
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *LogSettings) Set(b bool) {
|
||||||
|
newlog.Set(ls.name, b)
|
||||||
|
ls.checkbox.Set(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Node) NewLogFlag(name string) *LogSettings {
|
||||||
|
ls := new(LogSettings)
|
||||||
|
ls.parent = p
|
||||||
|
ls.ready = false
|
||||||
|
ls.name = name
|
||||||
|
|
||||||
|
ls.checkbox = p.NewCheckbox(name)
|
||||||
|
ls.label = p.NewLabel("Enable log." + name)
|
||||||
|
ls.checkbox.Set(newlog.Get(name))
|
||||||
|
ls.checkbox.Custom = func() {
|
||||||
|
newlog.Set(name, ls.checkbox.B)
|
||||||
|
}
|
||||||
|
return ls
|
||||||
|
}
|
||||||
|
|
||||||
// Let's you toggle on and off the various types of debugging output
|
// Let's you toggle on and off the various types of debugging output
|
||||||
// These checkboxes should be in the same order as the are printed
|
// These checkboxes should be in the same order as the are printed
|
||||||
func (n *Node) DebugFlags(makeWindow bool) {
|
func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
var w, g *Node
|
var w, g *Node
|
||||||
|
|
||||||
|
logGadgets := make(map[string]*LogSettings)
|
||||||
|
|
||||||
// Either:
|
// Either:
|
||||||
// make a new window
|
// make a new window
|
||||||
// make a new tab in the existing window
|
// make a new tab in the existing window
|
||||||
|
@ -17,6 +58,22 @@ func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
|
|
||||||
g = w.NewGroup("Show")
|
g = w.NewGroup("Show")
|
||||||
|
|
||||||
|
g.NewButton("log.SetTmp()", func () {
|
||||||
|
newlog.SetTmp()
|
||||||
|
})
|
||||||
|
|
||||||
|
g.NewButton("log.All(true)", func () {
|
||||||
|
for _, lf := range logGadgets {
|
||||||
|
lf.Set(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
g.NewButton("log.All(false)", func () {
|
||||||
|
for _, lf := range logGadgets {
|
||||||
|
lf.Set(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
g.NewButton("Dump Flags", func () {
|
g.NewButton("Dump Flags", func () {
|
||||||
ShowDebugValues()
|
ShowDebugValues()
|
||||||
})
|
})
|
||||||
|
@ -31,6 +88,12 @@ func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
|
|
||||||
g = w.NewGroup("List")
|
g = w.NewGroup("List")
|
||||||
g = g.NewGrid("flags grid", 2, 2)
|
g = g.NewGrid("flags grid", 2, 2)
|
||||||
|
|
||||||
|
logGadgets["INFO"] = g.NewLogFlag("INFO")
|
||||||
|
logGadgets["WARN"] = g.NewLogFlag("WARN")
|
||||||
|
logGadgets["SPEW"] = g.NewLogFlag("SPEW")
|
||||||
|
logGadgets["ERROR"] = g.NewLogFlag("ERROR")
|
||||||
|
|
||||||
// generally useful debugging
|
// generally useful debugging
|
||||||
cb1 := g.NewCheckbox("debug Gui")
|
cb1 := g.NewCheckbox("debug Gui")
|
||||||
g.NewLabel("like verbose=1")
|
g.NewLabel("like verbose=1")
|
||||||
|
@ -39,47 +102,6 @@ func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
log(debugGui, "Custom() n.widget =", cb1.Name, cb1.B)
|
log(debugGui, "Custom() n.widget =", cb1.Name, cb1.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
// errors. by default these always output somewhere
|
|
||||||
cbE := g.NewCheckbox("debug Error")
|
|
||||||
g.NewLabel("(bad things. default=true)")
|
|
||||||
cbE.Custom = func() {
|
|
||||||
SetFlag("Error", cbE.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
// debugging that will show you things like mouse clicks, user inputing text, etc
|
|
||||||
// also set toolkit.DebugChange
|
|
||||||
cb2 := g.NewCheckbox("debug Change")
|
|
||||||
g.NewLabel("keyboard and mouse events")
|
|
||||||
cb2.Custom = func() {
|
|
||||||
SetFlag("Change", cb2.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
// supposed to tell if you are going to dump full variable output
|
|
||||||
cb3 := g.NewCheckbox("debug Dump")
|
|
||||||
g.NewLabel("show lots of output")
|
|
||||||
cb3.Custom = func() {
|
|
||||||
SetFlag("Dump", cbE.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
cb4 := g.NewCheckbox("debug Tabs")
|
|
||||||
g.NewLabel("tabs and windows")
|
|
||||||
cb4.Custom = func() {
|
|
||||||
SetFlag("Tabs", cb4.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
cb6 := g.NewCheckbox("debug Node")
|
|
||||||
g.NewLabel("the binary tree)")
|
|
||||||
cb6.Custom = func() {
|
|
||||||
SetFlag("Node", cb6.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
// should show you when things go into or come back from the plugin
|
|
||||||
cb5 := g.NewCheckbox("debug Plugin")
|
|
||||||
g.NewLabel("plugin interaction)")
|
|
||||||
cb5.Custom = func() {
|
|
||||||
SetFlag("Plugin", cb5.B)
|
|
||||||
}
|
|
||||||
|
|
||||||
// turns on debugging inside the plugin toolkit
|
// turns on debugging inside the plugin toolkit
|
||||||
cb7 := g.NewCheckbox("debug Toolkit")
|
cb7 := g.NewCheckbox("debug Toolkit")
|
||||||
g.NewLabel("the plugin internals)")
|
g.NewLabel("the plugin internals)")
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
|
||||||
// "go.wit.com/gui/toolkit"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO: move all this shit into somewhere not global
|
// TODO: move all this shit into somewhere not global
|
||||||
|
|
||||||
// main debugging window
|
// main debugging window
|
||||||
|
@ -26,6 +22,7 @@ func DebugWindow() {
|
||||||
|
|
||||||
func (n *Node) DebugTab(title string) *Node {
|
func (n *Node) DebugTab(title string) *Node {
|
||||||
var newN, gog, g1 *Node
|
var newN, gog, g1 *Node
|
||||||
|
// var logSettings *gadgets.LogSettings
|
||||||
|
|
||||||
// time.Sleep(1 * time.Second)
|
// time.Sleep(1 * time.Second)
|
||||||
newN = n.NewTab(title)
|
newN = n.NewTab(title)
|
||||||
|
@ -42,7 +39,7 @@ func (n *Node) DebugTab(title string) *Node {
|
||||||
makeTabs = false
|
makeTabs = false
|
||||||
cb.Set(false)
|
cb.Set(false)
|
||||||
|
|
||||||
gog.NewButton("Debug Flags", func () {
|
gog.NewButton("logging", func () {
|
||||||
bugWin.DebugFlags(makeTabs)
|
bugWin.DebugFlags(makeTabs)
|
||||||
})
|
})
|
||||||
gog.NewButton("Debug Widgets", func () {
|
gog.NewButton("Debug Widgets", func () {
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
package gadgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
var myLogGui *LogSettings
|
||||||
|
|
||||||
|
type LogSettings struct {
|
||||||
|
ready bool
|
||||||
|
hidden bool
|
||||||
|
err error
|
||||||
|
|
||||||
|
parent *gui.Node // should be the root of the 'gui' package binary tree
|
||||||
|
window *gui.Node // our window for displaying the log package settings
|
||||||
|
group *gui.Node //
|
||||||
|
grid *gui.Node //
|
||||||
|
|
||||||
|
// Primary Directives
|
||||||
|
status *OneLiner
|
||||||
|
summary *OneLiner
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is initializes the main DO object
|
||||||
|
// You can only have one of these
|
||||||
|
func NewLogSettings(p *gui.Node) *LogSettings {
|
||||||
|
if myLogGui != nil {return myLogGui}
|
||||||
|
myLogGui = new(LogSettings)
|
||||||
|
myLogGui.parent = p
|
||||||
|
|
||||||
|
myLogGui.ready = false
|
||||||
|
|
||||||
|
myLogGui.window = p.NewWindow("Log Settings")
|
||||||
|
|
||||||
|
// make a group label and a grid
|
||||||
|
myLogGui.group = myLogGui.window.NewGroup("droplets:").Pad()
|
||||||
|
myLogGui.grid = myLogGui.group.NewGrid("grid", 2, 1).Pad()
|
||||||
|
|
||||||
|
myLogGui.ready = true
|
||||||
|
myLogGui.Hide()
|
||||||
|
return myLogGui
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the status is valid
|
||||||
|
func (d *LogSettings) Ready() bool {
|
||||||
|
if d == nil {return false}
|
||||||
|
return d.ready
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *LogSettings) Show() {
|
||||||
|
if ! d.Ready() {return}
|
||||||
|
log.Info("LogSettings.Show() window")
|
||||||
|
if d.hidden {
|
||||||
|
d.window.Show()
|
||||||
|
}
|
||||||
|
d.hidden = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *LogSettings) Hide() {
|
||||||
|
if ! d.Ready() {return}
|
||||||
|
log.Info("LogSettings.Hide() window")
|
||||||
|
if ! d.hidden {
|
||||||
|
d.window.Hide()
|
||||||
|
}
|
||||||
|
d.hidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *LogSettings) Update() bool {
|
||||||
|
if ! d.Ready() {return false}
|
||||||
|
return true
|
||||||
|
}
|
Loading…
Reference in New Issue