turns out log already does that
I gotta quit writing code before looking at docs ffs
This commit is contained in:
parent
d5f0151bb1
commit
ec9700a138
|
@ -46,7 +46,10 @@ func Initialise() AppConfig {
|
|||
if cfg, err := loadConfig(); err == nil {
|
||||
app.ListenPort = cfg.Port
|
||||
app.UseCache = cfg.UseCache
|
||||
app.LogLevel = logLevelFromString(cfg.LogLevel)
|
||||
app.LogLevel, err = log.ParseLevel(cfg.LogLevel)
|
||||
if err != nil {
|
||||
app.LogLevel = defaults.LogLevel
|
||||
}
|
||||
} else {
|
||||
app.Logger.Print("Failed loading config from environment", "err", err)
|
||||
}
|
||||
|
@ -66,23 +69,3 @@ func loadConfig() (ConfigDatabase, error) {
|
|||
return cfg, nil
|
||||
}
|
||||
}
|
||||
|
||||
// logLevelFromString turns a string like "warn" into a log.Level like log.WarnLevel
|
||||
func logLevelFromString(level string) log.Level {
|
||||
switch level {
|
||||
case "debug":
|
||||
return log.DebugLevel
|
||||
case "info":
|
||||
return log.InfoLevel
|
||||
case "warn":
|
||||
return log.WarnLevel
|
||||
case "error":
|
||||
return log.ErrorLevel
|
||||
case "fatal":
|
||||
return log.FatalLevel
|
||||
case "none":
|
||||
return math.MaxInt32
|
||||
default:
|
||||
return defaults.LogLevel
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue