diff options
| author | Jeff Carr <[email protected]> | 2025-03-17 05:35:57 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-17 05:35:57 -0500 |
| commit | 4523eda0fa2372d97fb5db800b79b53c218ef627 (patch) | |
| tree | 930be1dac9028f59e47a0c7f3d63b1c324de92b0 | |
| parent | 3acf47379260f2503ec12cd1d168df724d242bba (diff) | |
| -rw-r--r-- | init.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -157,12 +157,15 @@ func initPlugin() { } // todo: make this a tmp file that goes away if !me.stdout.disable { - log.Log(INFO, "stdout.disable == true. writing to /tmp/captureMode.log") - me.outf, err = os.OpenFile("/tmp/captureMode.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + tmpFile, err := os.CreateTemp("", "gocui-*.log") if err != nil { - log.Info("error opening file:", err) - os.Exit(0) + fmt.Println("Error creating temp file:", err) + standardExit() } + // defer os.Remove(tmpFile.Name()) + + log.Log(INFO, "stdout.disable == true. writing to", tmpFile.Name()) + me.outf = tmpFile // todo: some early output still goes to the /tmp/ file //time.Sleep(200 * time.Millisecond) log.CaptureMode(me.stdout) @@ -289,6 +292,7 @@ func standardExit() { if me.outf != nil { log.Log(NOW, "standardExit() doing outf.Close()") me.outf.Close() + os.Remove(me.outf.Name()) } // log(true, "standardExit() setOutput(os.Stdout)") // setOutput(os.Stdout) @@ -305,6 +309,7 @@ func standardClose() { me.baseGui.Close() log.Log(NOW, "standardExit() doing outf.Close()") me.outf.Close() + os.Remove(me.outf.Name()) // os.Stdin = os.Stdin // os.Stdout = os.Stdout // os.Stderr = os.Stderr |
