From 6d671b28ae3294d5ef4fed110f6351fbaf51600f Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Mon, 22 Nov 2021 18:51:49 -0800 Subject: [PATCH] Use preferred temp dir for debug log file --- cointop/cointop.go | 7 ++----- cointop/debug.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cointop/cointop.go b/cointop/cointop.go index fa47dda..6a7477a 100644 --- a/cointop/cointop.go +++ b/cointop/cointop.go @@ -224,10 +224,6 @@ var DefaultFavoriteChar = "*" // NewCointop initializes cointop func NewCointop(config *Config) (*Cointop, error) { - if os.Getenv("DEBUG") != "" { - log.SetLevel(log.DebugLevel) - } - if config == nil { config = &Config{} } @@ -317,7 +313,8 @@ func NewCointop(config *Config) (*Cointop, error) { Input: NewInputView(), }, } - ct.initlog() + + ct.setLogConfiguration() err := ct.SetupConfig() if err != nil { diff --git a/cointop/debug.go b/cointop/debug.go index 631168c..77f0a1e 100644 --- a/cointop/debug.go +++ b/cointop/debug.go @@ -8,8 +8,15 @@ import ( log "github.com/sirupsen/logrus" ) -func (ct *Cointop) initlog() { - filename := "/tmp/cointop.log" +func (ct *Cointop) setLogConfiguration() { + if os.Getenv("DEBUG") != "" { + log.SetLevel(log.DebugLevel) + ct.setLogOutputFile() + } +} + +func (ct *Cointop) setLogOutputFile() { + filename := pathutil.NormalizePath(":PREFERRED_TEMP_DIR:/cointop.log") debugFile := os.Getenv("DEBUG_FILE") if debugFile != "" { filename = pathutil.NormalizePath(debugFile)