WIP: updated log level on some log entries and added environment variable expansion for command line and its arguments
This commit is contained in:
@@ -30,6 +30,7 @@ const (
|
||||
WMPidProxyPathFlag = "pid-proxy"
|
||||
WMExecPathFlag = "exec"
|
||||
PathConfigFlag = "config"
|
||||
GlobalLogConfig = "log_level"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -84,9 +85,11 @@ func Read() (*Config, error) {
|
||||
_ = viper.BindEnv(PathConfig)
|
||||
_ = viper.BindEnv(PidProxyPathConfig)
|
||||
_ = viper.BindEnv(ExecPathConfig)
|
||||
_ = viper.BindEnv(GlobalLogConfig)
|
||||
viper.SetDefault(PathConfig, DefaultConfigPath)
|
||||
viper.SetDefault(PidProxyPathConfig, PidProxyPathDefault)
|
||||
viper.SetDefault(ExecPathConfig, ExecPathDefault)
|
||||
viper.SetDefault(GlobalLogConfig, wingmate.InfoLevelStr)
|
||||
|
||||
var (
|
||||
dirent []os.DirEntry
|
||||
@@ -101,6 +104,7 @@ func Read() (*Config, error) {
|
||||
crones []CronTask
|
||||
)
|
||||
|
||||
wingmate.SetGlobalLevelStr(viper.GetString(GlobalLogConfig))
|
||||
serviceAvailable = false
|
||||
cronAvailable = false
|
||||
outConfig := &Config{
|
||||
@@ -111,7 +115,7 @@ func Read() (*Config, error) {
|
||||
svcdir = filepath.Join(configPath, ServiceDirName)
|
||||
dirent, err = os.ReadDir(svcdir)
|
||||
if err != nil {
|
||||
wingmate.Log().Error().Msgf("encounter error when reading service directory %s: %+v", svcdir, err)
|
||||
wingmate.Log().Warn().Msgf("encounter error when reading service directory %s: %+v", svcdir, err)
|
||||
}
|
||||
if len(dirent) > 0 {
|
||||
for _, d := range dirent {
|
||||
@@ -134,7 +138,7 @@ func Read() (*Config, error) {
|
||||
cronAvailable = true
|
||||
}
|
||||
if err != nil {
|
||||
wingmate.Log().Error().Msgf("encounter error when reading crontab %s: %+v", crontabfile, err)
|
||||
wingmate.Log().Warn().Msgf("encounter error when reading crontab %s: %+v", crontabfile, err)
|
||||
}
|
||||
|
||||
wingmateConfigAvailable = false
|
||||
|
||||
Reference in New Issue
Block a user