Use preferred temp dir for debug log file

pull/293/head
Miguel Mota 2 years ago
parent 62ce8e1adb
commit 6d671b28ae
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -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 {

@ -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)

Loading…
Cancel
Save