Skip to content

Commit

Permalink
fix(logger): Redirect logs to stderr instead of stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut-gauvin committed Jan 29, 2024
1 parent beecd1e commit d723498
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ func initConfig() {
viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
logger.Infof("Using config file: %s", viper.ConfigFileUsed())
if err := viper.ReadInConfig(); err != nil {
logger.Errorf("Unable read from config: %s", err)
os.Exit(1)
}
logger.Infof("Using config file: %s", viper.ConfigFileUsed())
}

func initConfigFile() {
Expand All @@ -99,7 +101,7 @@ func initConfigFile() {
viper.SetConfigFile(configFile)
return
}
fmt.Printf("Config file not found at %s\n", configFile) //nolint: forbidigo
logger.Errorf("Config file not found at \"%s\"", configFile)
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
logger atomic.Value
defaultLevel = "info"
defaultLogger = Logger{
Writer: os.Stdout,
Writer: os.Stderr,
Level: LogLevelInfo,
}

Expand Down

0 comments on commit d723498

Please sign in to comment.