moved utils from internal to pkg

This commit is contained in:
DataHearth 2021-03-14 16:02:27 +01:00
parent 50b4b42539
commit 45ebb35066
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
2 changed files with 12 additions and 13 deletions

View File

@ -6,26 +6,23 @@ import (
)
// LoadConfig will read the yaml config from the viper config path
func LoadConfig(log logrus.FieldLogger) error {
logger := log.WithFields(logrus.Fields{
func LoadConfig() {
logger := logrus.WithFields(logrus.Fields{
"pkg": "utils",
"component": "config",
})
if err := viper.ReadInConfig(); err != nil {
logger.WithError(err).Errorln(ErrReadConfigFile.Error())
return err
logger.WithError(err).Fatalln("failed to load configuration file")
}
return nil
}
// SetupLogger setup the root logger
func SetupLogger(logger *logrus.Logger) {
var (
level = logrus.InfoLevel
timestamp = true
color = true
level = logrus.InfoLevel
timestamp = true
color = true
loggerConfig = viper.GetStringMap("logger")
)
@ -47,9 +44,9 @@ func SetupLogger(logger *logrus.Logger) {
logger.SetLevel(level)
logger.SetFormatter(&logrus.TextFormatter{
DisableColors: color,
ForceColors: true,
FullTimestamp: true,
DisableColors: color,
ForceColors: true,
FullTimestamp: true,
DisableTimestamp: timestamp,
})
}

View File

@ -5,4 +5,6 @@ import "errors"
var (
// ErrReadConfigFile is thrown when viper failed to read config file
ErrReadConfigFile = errors.New("failed to read config file")
)
// ErrNilLogger is thrown when the parameter logger is nil
ErrNilLogger = errors.New("logger can't be nil")
)