summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-17 05:35:57 -0500
committerJeff Carr <[email protected]>2025-03-17 05:35:57 -0500
commit4523eda0fa2372d97fb5db800b79b53c218ef627 (patch)
tree930be1dac9028f59e47a0c7f3d63b1c324de92b0
parent3acf47379260f2503ec12cd1d168df724d242bba (diff)
remove the tmp filev0.22.42v0.22.41v0.22.40
-rw-r--r--init.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/init.go b/init.go
index 87cec5a..b13f634 100644
--- a/init.go
+++ b/init.go
@@ -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