You've already forked armbian-router
mirror of
https://github.com/armbian/armbian-router.git
synced 2026-01-06 10:37:03 -08:00
config: allow setting log level from yaml config
This commit is contained in:
14
config.go
14
config.go
@@ -56,6 +56,11 @@ type Config struct {
|
||||
// Special extensions for the download map
|
||||
SpecialExtensions map[string]string `mapstructure:"specialExtensions"`
|
||||
|
||||
// LogLevel is the log level to use for the application.
|
||||
// It can be one of: "debug", "info", "warn", "error", "fatal", "panic".
|
||||
// If not set, it defaults to "warn".
|
||||
LogLevel string `mapstructure:"logLevel"`
|
||||
|
||||
// ReloadFunc is called when a reload is done via http api.
|
||||
ReloadFunc func()
|
||||
|
||||
@@ -112,6 +117,15 @@ func (r *Redirector) ReloadConfig() error {
|
||||
}
|
||||
}
|
||||
|
||||
// set log level
|
||||
level, err := log.ParseLevel(r.config.LogLevel)
|
||||
if err != nil {
|
||||
log.WithField("level", r.config.LogLevel).Warning("Invalid log level, using default")
|
||||
level = log.WarnLevel
|
||||
}
|
||||
|
||||
log.SetLevel(level)
|
||||
|
||||
// db can be hot-reloaded if the file changed
|
||||
r.db, err = maxminddb.Open(r.config.GeoDBPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user