diff --git a/gocui.go b/gocui.go index 05672ec..1118a7d 100644 --- a/gocui.go +++ b/gocui.go @@ -30,6 +30,11 @@ func gocuiEvent(g *gocui.Gui) error { makeOutputWidget(g, "this is a create before a mouse click") if me.logStdout != nil { // setOutput(me.logStdout) + // me.logStdout.Write("test out") + w := me.logStdout.TK.(*guiWidget) + w.Write([]byte("test out")) + // log.CaptureMode(w) + log.Log(NOW, "logStdout test out") } } else { log.Verbose("output widget already exists", maxX, maxY, mx, my) diff --git a/main.go b/main.go index 5a4241c..9ed14ff 100644 --- a/main.go +++ b/main.go @@ -90,32 +90,18 @@ func mainGogui() { log.Warn("YAHOOOO Recovered in guiMain application:", r) log.Warn("Recovered from panic:", r) me.baseGui.Close() + log.CaptureMode(nil) + log.Warn("YAHOOOO Recovered in guiMain application:", r) + log.Warn("Recovered from panic:", r) me.myTree.SendToolkitPanic() - // attempts to control STDOUT - /* - // allow gocui to close if possible, then print stack - log.Sleep(1) - me.myTree.SendToolkitLoad("nocui") - log.Sleep(3) - os.Stdout = origStdout - os.Stderr = origStderr - log.Warn("Stack trace:") - debug.PrintStack() - - // attempt to switch to the nocui toolkit - log.Sleep(1) - // panic("BUMMER") - */ return } }() - // attempts to control STDOUT - /* - var err error - log.Log(INFO, "main() start Init()") - outf, err = os.OpenFile("/tmp/witgui.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + var err error + + outf, err = os.OpenFile("/tmp/captureMode.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { log.Error(err, "error opening file: %v") os.Exit(0) @@ -124,13 +110,8 @@ func mainGogui() { os.Stdout = outf defer outf.Close() - // setOutput(outf) - // log("This is a test log entry") + log.CaptureMode(outf) - ferr, _ := os.OpenFile("/tmp/witgui.err", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664) - origStderr = os.Stderr - os.Stderr = ferr - */ gocuiMain() } diff --git a/showStdout.go b/showStdout.go index 22e6d8e..7201d27 100644 --- a/showStdout.go +++ b/showStdout.go @@ -38,7 +38,9 @@ func showMsg(g *gocui.Gui, v *gocui.View) error { l = "" } - makeOutputWidget(g, l) + outv := makeOutputWidget(g, l) + outv.Write([]byte("test out2")) + log.Info("test out2") return nil }