Tobias Trabelsi
b72c1d1edb
Reviewed-on: #1 Co-authored-by: Tobias Trabelsi <lerentis@uploadfilter24.eu> Co-committed-by: Tobias Trabelsi <lerentis@uploadfilter24.eu>
29 lines
561 B
Go
29 lines
561 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
|
|
"git.uploadfilter24.eu/covidnetes/metallb-ip-floater/internal"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func ConfigureLogger(cfg *internal.Config) {
|
|
|
|
switch cfg.LogLevel {
|
|
case "Debug":
|
|
log.SetLevel(log.DebugLevel)
|
|
case "Info":
|
|
log.SetLevel(log.InfoLevel)
|
|
case "Warn":
|
|
log.SetLevel(log.WarnLevel)
|
|
case "Error":
|
|
log.SetLevel(log.ErrorLevel)
|
|
default:
|
|
log.SetLevel(log.InfoLevel)
|
|
log.Warnf("Home: invalid log level supplied: '%s'", cfg.LogLevel)
|
|
}
|
|
|
|
log.SetFormatter(&log.JSONFormatter{})
|
|
log.SetOutput(os.Stdout)
|
|
}
|