Skip to content

Commit

Permalink
Bug fix, logger level always get info level
Browse files Browse the repository at this point in the history
  • Loading branch information
jneo8 committed Jun 18, 2020
1 parent e8e6e1f commit bb4a6b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func NewLogger() *log.Logger {

// SetLoggerLevel setup logger's log level using viper "log_level" field .
func SetLoggerLevel(logger *log.Logger, cfg *viper.Viper) {
cfg.SetDefault("log_level", "Info")
level := cfg.GetString("log_level")
switch level {
case "Debug":
Expand All @@ -35,4 +34,5 @@ func SetLoggerLevel(logger *log.Logger, cfg *viper.Viper) {
default:
logger.SetLevel(log.InfoLevel)
}
logger.Infof("Log level: %s", logger.GetLevel().String())
}
3 changes: 3 additions & 0 deletions mermaid.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (m *Mermaid) Bind() error {
// BindViper will
// - load config file if exists.
// - load environment with prefix.
// - set default log level field.
func (m *Mermaid) BindViper() {

// Read config from giving file path or filename.yaml.
Expand Down Expand Up @@ -128,4 +129,6 @@ func (m *Mermaid) BindViper() {
m.Config.AutomaticEnv()
m.Config.SetEnvPrefix(m.ENVPrefix)
m.Config.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
// Set default log level.
m.Config.SetDefault("log_level", "Info")
}

0 comments on commit bb4a6b6

Please sign in to comment.