Log server details only if log level is INFO or lower

This commit is contained in:
ByteDream 2023-02-22 00:33:51 +01:00
parent 192d0377c6
commit 8c219712f0
3 changed files with 52 additions and 42 deletions

View file

@ -462,3 +462,20 @@ func LookupEnvOrStrings(key string, defaultVal []string) []string {
}
return defaultVal
}
func ParseLogLevel(lvl string) (log.Lvl, error) {
switch strings.ToLower(lvl) {
case "debug":
return log.DEBUG, nil
case "info":
return log.INFO, nil
case "warn":
return log.WARN, nil
case "error":
return log.ERROR, nil
case "off":
return log.OFF, nil
default:
return log.DEBUG, fmt.Errorf("not a valid log level: %s", lvl)
}
}