Skip to content

Commit

Permalink
Don't display warning log in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jul 16, 2019
1 parent 9064de4 commit f52abb2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func getConfigurationFileWithENVPrefix(file, env string) (string, time.Time, err
return "", time.Now(), fmt.Errorf("failed to find file %v", file)
}

func (configor *Configor) getConfigurationFiles(files ...string) ([]string, map[string]time.Time) {
func (configor *Configor) getConfigurationFiles(watchMode bool, files ...string) ([]string, map[string]time.Time) {
var resultKeys []string
var results = map[string]time.Time{}

if configor.Config.Debug || configor.Config.Verbose {
if !watchMode && (configor.Config.Debug || configor.Config.Verbose) {
fmt.Printf("Current environment: '%v'\n", configor.GetEnvironment())
}

Expand All @@ -85,7 +85,7 @@ func (configor *Configor) getConfigurationFiles(files ...string) ([]string, map[
// check example configuration
if !foundFile {
if example, modTime, err := getConfigurationFileWithENVPrefix(file, "example"); err == nil {
if !configor.Silent {
if !watchMode && !configor.Silent {
fmt.Printf("Failed to find configuration %v, using example file %v\n", file, example)
}
resultKeys = append(resultKeys, example)
Expand Down Expand Up @@ -310,7 +310,7 @@ func (configor *Configor) load(config interface{}, watchMode bool, files ...stri
}
}()

configFiles, configModTimeMap := configor.getConfigurationFiles(files...)
configFiles, configModTimeMap := configor.getConfigurationFiles(watchMode, files...)

if watchMode {
if len(configModTimeMap) == len(configor.configModTimes) {
Expand Down

0 comments on commit f52abb2

Please sign in to comment.