diff options
Diffstat (limited to 'gocui/main.go')
| -rw-r--r-- | gocui/main.go | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/gocui/main.go b/gocui/main.go index 5157ecd..8c079c9 100644 --- a/gocui/main.go +++ b/gocui/main.go @@ -6,24 +6,26 @@ package main import ( "os" + + "go.wit.com/log" "go.wit.com/gui/widget" ) // sets defaults and establishes communication // to this toolkit from the wit/gui golang package func init() { - log(logInfo, "Init() of awesome-gocui") + log.Log(INFO, "Init() of awesome-gocui") // init the config struct default values Set(&me, "default") pluginChan = make(chan widget.Action) - log(logNow, "Init() start pluginChan") + log.Log(NOW, "Init() start pluginChan") go catchActionChannel() - sleep(.1) // probably not needed, but in here for now under development + log.Sleep(.1) // probably not needed, but in here for now under development go main() - sleep(.1) // probably not needed, but in here for now under development + log.Sleep(.1) // probably not needed, but in here for now under development } /* @@ -33,17 +35,17 @@ recieves requests from the program to do things like: * etc.. */ func catchActionChannel() { - log(logInfo, "catchActionChannel() START") + log.Log(INFO, "catchActionChannel() START") for { - log(logInfo, "catchActionChannel() infinite for() loop restarted select on channel") + log.Log(INFO, "catchActionChannel() infinite for() loop restarted select on channel") select { case a := <-pluginChan: if (me.baseGui == nil) { // something went wrong initializing the gocui - log(logError,"ERROR: console did not initialize") + log.Log(ERROR, "ERROR: console did not initialize") continue } - log(logInfo, "catchActionChannel()", a.WidgetId, a.ActionType, a.WidgetType, a.Name) + log.Log(INFO, "catchActionChannel()", a.WidgetId, a.ActionType, a.WidgetType, a.Name) action(&a) } } @@ -51,23 +53,23 @@ func catchActionChannel() { func Exit() { // TODO: what should actually happen here? - log(true, "Exit() here. doing standardExit()") + log.Log(NOW, "Exit() here. doing standardExit()") standardExit() } func standardExit() { - log(true, "standardExit() doing baseGui.Close()") + log.Log(NOW, "standardExit() doing baseGui.Close()") me.baseGui.Close() - log(true, "standardExit() doing outf.Close()") + log.Log(NOW, "standardExit() doing outf.Close()") outf.Close() // log(true, "standardExit() setOutput(os.Stdout)") // setOutput(os.Stdout) - log(true, "standardExit() send back Quit()") + log.Log(NOW, "standardExit() send back Quit()") go sendBackQuit() // don't stall here in case the // induces a delay in case the callback channel is broken - sleep(1) - log(true, "standardExit() exit()") - exit() + log.Sleep(1) + log.Log(NOW, "standardExit() exit()") + os.Exit(0) } func sendBackQuit() { // send 'Quit' back to the program (?) @@ -80,11 +82,12 @@ var outf *os.File func main() { var err error - log(logInfo, "main() start Init()") + log.Log(INFO, "main() start Init()") outf, err = os.OpenFile("/tmp/witgui.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666) if err != nil { - exit("error opening file: %v", err) + log.Error(err, "error opening file: %v") + os.Exit(0) } os.Stdout = outf defer outf.Close() @@ -96,6 +99,6 @@ func main() { os.Stderr = ferr gocuiMain() - log(true, "MouseMain() closed") + log.Log(NOW, "MouseMain() closed") standardExit() } |
