Correctly use configured loglevel
This commit is contained in:
parent
056ac87eee
commit
9db21cb15d
@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/go-systemd/daemon"
|
||||
@ -264,7 +265,19 @@ func setupLoggers(cfg config.Config) *loggerCollection {
|
||||
logEncoderCfg := zap.NewProductionEncoderConfig()
|
||||
logEncoderCfg.EncodeCaller = func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {}
|
||||
|
||||
level := zap.NewAtomicLevelAt(zap.InfoLevel)
|
||||
var level zap.AtomicLevel
|
||||
switch strings.ToUpper(cfg.Honeypot.LogLevel) {
|
||||
case "INFO":
|
||||
level = zap.NewAtomicLevelAt(zap.InfoLevel)
|
||||
case "DEBUG":
|
||||
level = zap.NewAtomicLevelAt(zap.DebugLevel)
|
||||
case "WARN", "WARNING":
|
||||
level = zap.NewAtomicLevelAt(zap.WarnLevel)
|
||||
case "ERR", "ERROR":
|
||||
level = zap.NewAtomicLevelAt(zap.WarnLevel)
|
||||
default:
|
||||
level = zap.NewAtomicLevelAt(zap.InfoLevel)
|
||||
}
|
||||
logEncoderCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
logEncoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
logEncoderCfg.EncodeDuration = zapcore.StringDurationEncoder
|
||||
|
Loading…
Reference in New Issue
Block a user