refactor: use central logger

This commit is contained in:
2024-07-07 23:45:37 +02:00
parent cf8ff410cc
commit ef108d63e1
86 changed files with 903 additions and 889 deletions

View File

@ -5,7 +5,7 @@ import (
"path"
"path/filepath"
"github.com/sirupsen/logrus"
"coopcloud.tech/abra/pkg/log"
"gopkg.in/yaml.v3"
)
@ -16,13 +16,13 @@ func LoadAbraConfig() Abra {
wd, _ := os.Getwd()
configFile := findAbraConfig(wd)
if configFile == "" {
logrus.Debugf("no config file found")
log.Debugf("no config file found")
return Abra{}
}
data, err := os.ReadFile(configFile)
if err != nil {
// Do nothing, when an error occurs
logrus.Debugf("error reading config file: %s", err)
log.Debugf("error reading config file: %s", err)
return Abra{}
}
@ -30,10 +30,10 @@ func LoadAbraConfig() Abra {
err = yaml.Unmarshal(data, &config)
if err != nil {
// Do nothing, when an error occurs
logrus.Debugf("error loading config file: %s", err)
log.Debugf("error loading config file: %s", err)
return Abra{}
}
logrus.Debugf("config file loaded from: %s", configFile)
log.Debugf("config file loaded from: %s", configFile)
config.configPath = configFile
return config
}
@ -73,18 +73,18 @@ type Abra struct {
// 3. use $HOME/.abra when above two options failed
func (a Abra) GetAbraDir() string {
if dir, exists := os.LookupEnv("ABRA_DIR"); exists && dir != "" {
logrus.Debug("read abra dir from $ABRA_DIR")
log.Debug("read abra dir from $ABRA_DIR")
return dir
}
if a.AbraDir != "" {
logrus.Debug("read abra dir from config file")
log.Debug("read abra dir from config file")
if path.IsAbs(a.AbraDir) {
return a.AbraDir
}
// Make the path absolute
return path.Join(a.configPath, a.AbraDir)
}
logrus.Debug("using default abra dir")
log.Debug("using default abra dir")
return os.ExpandEnv("$HOME/.abra")
}