diff --git a/cmd/apiary.go b/cmd/apiary.go index e6b8cfb..c61e90a 100644 --- a/cmd/apiary.go +++ b/cmd/apiary.go @@ -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