[#230] Refactor logger tag configuration
All checks were successful
/ DCO (pull_request) Successful in 42s
/ Vulncheck (pull_request) Successful in 1m2s
/ Builds (pull_request) Successful in 1m34s
/ OCI image (pull_request) Successful in 1m52s
/ Lint (pull_request) Successful in 2m37s
/ Tests (pull_request) Successful in 1m36s
/ Integration tests (pull_request) Successful in 6m31s
/ Builds (push) Successful in 1m6s
/ Vulncheck (push) Successful in 1m8s
/ Lint (push) Successful in 2m13s
/ Tests (push) Successful in 1m8s
/ Integration tests (push) Successful in 5m48s
/ OCI image (push) Successful in 1m37s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2025-04-16 17:53:49 +03:00 committed by Alexey Vanin
parent b9f1f455f8
commit b7b08d9d82
3 changed files with 5 additions and 14 deletions

View file

@ -40,7 +40,7 @@ type zapCoreTagFilterWrapper struct {
}
type TagFilterSettings interface {
LevelEnabled(tag string, tgtLevel zapcore.Level) bool
LevelEnabled(tag string, lvl zapcore.Level) bool
DefaultEnabled(lvl zapcore.Level) bool
}
@ -130,14 +130,13 @@ func newLogEncoder() zapcore.Encoder {
//
// See also zapcore.Level, zap.NewProductionConfig, zap.AddStacktrace.
func newStdoutLogger(v *viper.Viper, lvl zap.AtomicLevel, loggerSettings LoggerAppSettings, tagSetting TagFilterSettings) *Logger {
stdout := zapcore.AddSync(os.Stderr)
stdout := zapcore.AddSync(os.Stdout)
consoleOutCore := zapcore.NewCore(newLogEncoder(), stdout, lvl)
consoleOutCore = applyZapCoreMiddlewares(consoleOutCore, v, loggerSettings, tagSetting)
return &Logger{
logger: zap.New(consoleOutCore, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel))),
lvl: lvl,
}
}
@ -155,7 +154,6 @@ func newJournaldLogger(v *viper.Viper, lvl zap.AtomicLevel, loggerSettings Logge
return &Logger{
logger: zap.New(coreWithContext, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel))),
lvl: lvl,
}
}