quiet logging

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-21 10:25:41 -06:00
parent 8a07a26f2a
commit b19c1e237d
5 changed files with 39 additions and 20 deletions

View File

@ -18,7 +18,7 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node {
n.Strings = make(map[string]int) n.Strings = make(map[string]int)
if a.WidgetType == widget.Root { if a.WidgetType == widget.Root {
log.Info("AddNode() Root") log.Log(TREE, "AddNode() Root")
n.Parent = n n.Parent = n
me.treeRoot = n me.treeRoot = n
return n return n
@ -40,8 +40,8 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node {
log.Warn("AddNode() ERROR n.Parent == nil", a.WidgetId, a.ParentId, a.WidgetType) log.Warn("AddNode() ERROR n.Parent == nil", a.WidgetId, a.ParentId, a.WidgetType)
return n return n
} }
log.Warn("AddNode() Adding to parent =", p.ParentId, p.WidgetType, p.GetProgName()) log.Log(TREE, "AddNode() Adding to parent =", p.ParentId, p.WidgetType, p.GetProgName())
log.Warn("AddNode() Adding child =", n.ParentId, n.WidgetType, n.GetProgName()) log.Log(TREE, "AddNode() Adding child =", n.ParentId, n.WidgetType, n.GetProgName())
p.children = append(p.children, n) p.children = append(p.children, n)
return n return n
} }
@ -49,14 +49,14 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node {
func (n *Node) DeleteNode() { func (n *Node) DeleteNode() {
p := n.Parent p := n.Parent
for i, child := range p.children { for i, child := range p.children {
log.Warn("parent has child:", i, child.WidgetId, child.GetProgName()) log.Log(TREE, "parent has child:", i, child.WidgetId, child.GetProgName())
if n == child { if n == child {
log.Warn("Found child ==", i, child.WidgetId, child.GetProgName()) log.Log(TREE, "Found child ==", i, child.WidgetId, child.GetProgName())
log.Warn("Found n ==", i, n.WidgetId, n.GetProgName()) log.Log(TREE, "Found n ==", i, n.WidgetId, n.GetProgName())
p.children = append(p.children[:i], p.children[i+1:]...) p.children = append(p.children[:i], p.children[i+1:]...)
} }
} }
for i, child := range p.children { for i, child := range p.children {
log.Warn("parent now has child:", i, child.WidgetId, child.GetProgName()) log.Log(TREE, "parent now has child:", i, child.WidgetId, child.GetProgName())
} }
} }

View File

@ -51,9 +51,9 @@ func (me *TreeInfo) SendToolkitPanic() {
var a widget.Action var a widget.Action
a.ActionType = widget.ToolkitPanic a.ActionType = widget.ToolkitPanic
a.ProgName = me.PluginName a.ProgName = me.PluginName
log.Info("SendUserEvent() START: toolkit panic()") log.Log(TREE, "SendUserEvent() START: toolkit panic()")
me.callback <- a me.callback <- a
log.Info("SendUserEvent() END: toolkit panic()") log.Log(TREE, "SendUserEvent() END: toolkit panic()")
return return
} }
@ -65,9 +65,9 @@ func (me *TreeInfo) SendWindowCloseEvent(n *Node) {
var a widget.Action var a widget.Action
a.WidgetId = n.WidgetId a.WidgetId = n.WidgetId
a.ActionType = widget.CloseWindow a.ActionType = widget.CloseWindow
log.Info("SendUserEvent() START: user closed the window", n.GetProgName()) log.Log(TREE, "SendUserEvent() START: user closed the window", n.GetProgName())
me.callback <- a me.callback <- a
log.Info("SendUserEvent() END: user closed the window", n.GetProgName()) log.Log(TREE, "SendUserEvent() END: user closed the window", n.GetProgName())
return return
} }
@ -82,10 +82,10 @@ func (me *TreeInfo) SendUserEvent(n *Node) {
a.Value = n.State.Value a.Value = n.State.Value
a.ActionType = widget.User a.ActionType = widget.User
if n.WidgetType == widget.Checkbox { if n.WidgetType == widget.Checkbox {
log.Info("SendUserEvent() checkbox going to send:", a.Value) log.Log(TREE, "SendUserEvent() checkbox going to send:", a.Value)
} }
log.Info("SendUserEvent() START: send a user event to the callback channel") log.Log(TREE, "SendUserEvent() START: send a user event to the callback channel")
me.callback <- a me.callback <- a
log.Info("SendUserEvent() END: sent a user event to the callback channel") log.Log(TREE, "SendUserEvent() END: sent a user event to the callback channel")
return return
} }

13
flags.go Normal file
View File

@ -0,0 +1,13 @@
package tree
import (
"go.wit.com/log"
)
var TREE *log.LogFlag
func init() {
full := "go.wit.com/gui"
short := "tree"
TREE = log.NewFlag("TREE", false, full, short, "treeRoot info")
}

16
init.go
View File

@ -18,9 +18,9 @@ func (me *TreeInfo) catchActionChannel() {
panic(-1) panic(-1)
} }
}() }()
log.Info("catchActionChannel() START") log.Log(TREE, "catchActionChannel() START")
for { for {
log.Info("catchActionChannel() for loop") log.Log(TREE, "catchActionChannel() for loop")
select { select {
case a := <-me.pluginChan: case a := <-me.pluginChan:
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName) log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName)
@ -41,7 +41,7 @@ func (me *TreeInfo) catchActionChannel() {
me.ActionFromChannel(a) me.ActionFromChannel(a)
} }
muAction.Unlock() muAction.Unlock()
// log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType) // log.Log(TREE, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
} }
} }
} }
@ -50,8 +50,14 @@ func New() *TreeInfo {
me := new(TreeInfo) me := new(TreeInfo)
me.pluginChan = make(chan widget.Action, 1) me.pluginChan = make(chan widget.Action, 1)
log.Info("Init() start channel reciever") /*
full := "go.wit.com/gui"
short := "gui"
TREE = log.NewFlag("TREE", true, full, short, "treeRoot info")
*/
log.Log(TREE, "Init() start channel reciever")
go me.catchActionChannel() go me.catchActionChannel()
log.Info("Init() END") log.Log(TREE, "Init() END")
return me return me
} }

View File

@ -54,7 +54,7 @@ func (n *Node) Json() []string {
log.Warn(tmp) log.Warn(tmp)
return all return all
default: default:
log.Info("doUserEvent() type =", n.WidgetType) log.Log(TREE, "doUserEvent() type =", n.WidgetType)
} }
return all return all
} }