[LOGGING] Fix #28: Ajouter sampling à NewLoggerWithRotation
This commit is contained in:
parent
7ed41e56d4
commit
2e2f5da4df
1 changed files with 11 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue