Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect log level settings #904

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@ func NewContext() *LogContext {

// SetLogLevel sets the log level to use for the logger
func SetLogLevel(logLevel string) error {
var level logrus.Level
switch strings.ToLower(logLevel) {
case "trace":
logger.SetLevel(logrus.TraceLevel)
level = logrus.TraceLevel
case "debug":
logger.SetLevel(logrus.DebugLevel)
level = logrus.DebugLevel
case "info":
logger.SetLevel(logrus.InfoLevel)
level = logrus.InfoLevel
case "warn":
logger.SetLevel(logrus.WarnLevel)
level = logrus.WarnLevel
case "error":
logger.SetLevel(logrus.ErrorLevel)
level = logrus.ErrorLevel
default:
return fmt.Errorf("invalid loglevel: %s", logLevel)
}
logger.SetLevel(level)
logrus.SetLevel(level) // set loglevel for the default logrus.logger
return nil
}

Expand Down