From 2e2f5da4dfb3544e27590a682ce33f201b6d767c Mon Sep 17 00:00:00 2001 From: senke Date: Sat, 27 Dec 2025 02:03:47 +0100 Subject: [PATCH] =?UTF-8?q?[LOGGING]=20Fix=20#28:=20Ajouter=20sampling=20?= =?UTF-8?q?=C3=A0=20NewLoggerWithRotation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- veza-backend-api/internal/logging/logger.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/veza-backend-api/internal/logging/logger.go b/veza-backend-api/internal/logging/logger.go index 351cbb897..32bbb4884 100644 --- a/veza-backend-api/internal/logging/logger.go +++ b/veza-backend-api/internal/logging/logger.go @@ -103,6 +103,17 @@ func NewLoggerWithRotation(env, logFile, logLevel string) (*Logger, error) { // En cas d'erreur de parsing, utiliser INFO par défaut level = zapcore.InfoLevel } + config.Level = zap.NewAtomicLevelAt(level) + + // FIX #28: Ajouter sampling en production/staging pour éviter spam + // Initial: log les 100 premiers messages par seconde + // Thereafter: log 1 message toutes les 100 messages suivants + if env == "production" || env == "staging" { + config.Sampling = &zap.SamplingConfig{ + Initial: 100, + Thereafter: 100, + } + } // Configuration de la rotation des logs avec lumberjack // Rotation par taille (100MB) et temps (daily)