remove the tmp file
This commit is contained in:
parent
3acf473792
commit
4523eda0fa
13
init.go
13
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
|
||||
|
|
Loading…
Reference in New Issue