[LOGGING] Fix #28: Ajouter sampling à NewLoggerWithRotation

This commit is contained in:
senke 2025-12-27 02:03:47 +01:00
parent 7ed41e56d4
commit 2e2f5da4df

View file

@ -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)