Skip to content

Commit

Permalink
Changes to use ParseLevel(string)
Browse files Browse the repository at this point in the history
  • Loading branch information
joereuss12 committed Oct 16, 2023
1 parent 55c990f commit 8b3a0a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
24 changes: 5 additions & 19 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,11 @@ func initConfig() {
if param.Debug.GetBool() {
setLogging(log.DebugLevel)
} else {
switch logLevel := param.Logging_LogLevel.GetString(); logLevel {
case "TraceLevel":
setLogging(log.TraceLevel)
case "DebugLevel":
setLogging(log.DebugLevel)
case "InfoLevel":
setLogging(log.InfoLevel)
case "WarnLevel":
setLogging(log.WarnLevel)
case "ErrorLevel":
setLogging(log.ErrorLevel) //This should be the default if unchanged
case "FatalLevel":
setLogging(log.FatalLevel)
case "PanicLevel":
setLogging(log.PanicLevel)
default:
setLogging(log.ErrorLevel)
log.Errorf("LogLevel set in config is not a valid level: %s", logLevel)
os.Exit(1)
logLevel := param.Logging_LogLevel.GetString()
level, err := log.ParseLevel(logLevel)
if err != nil {
panic(err)
}
setLogging(level)
}
}
2 changes: 1 addition & 1 deletion config/resources/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

Debug: false
Logging:
LogLevel: "ErrorLevel"
LogLevel: "Error"
Server:
Port: 8444
Address: "0.0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ components: ["client", "nsregistry", "director"]
############################
name: Logging.LogLevel
description: >-
A string defining the log level of the client. Options include (going from most info to least): TraceLevel, DebugLevel, InfoLevel, WarnLevel, ErrorLevel, FatalLevel, PanicLevel.
A string defining the log level of the client. Options include (going from most info to least): Trace, Debug, Info, Warn, Error, Fatal, Panic.
type: string
default: ErrorLevel
components: ["*"]
Expand Down

0 comments on commit 8b3a0a8

Please sign in to comment.