[LOGGING] Fix #25: Standardisation formats logs - JSON en prod/staging partout
This commit is contained in:
parent
524a35ce51
commit
c763237628
2 changed files with 8 additions and 5 deletions
|
|
@ -21,9 +21,10 @@ type Logger struct {
|
|||
func NewLogger(env, logLevel string) (*Logger, error) {
|
||||
var config zap.Config
|
||||
|
||||
if env == "production" {
|
||||
// FIX #25: Standardiser sur JSON en production/staging, console en développement
|
||||
if env == "production" || env == "staging" {
|
||||
config = zap.NewProductionConfig()
|
||||
// En production, utiliser JSON structuré
|
||||
// En production/staging, utiliser JSON structuré pour faciliter l'agrégation
|
||||
config.Encoding = "json"
|
||||
config.EncoderConfig = zap.NewProductionEncoderConfig()
|
||||
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
|
|
@ -67,9 +68,10 @@ func NewLogger(env, logLevel string) (*Logger, error) {
|
|||
func NewLoggerWithRotation(env, logFile, logLevel string) (*Logger, error) {
|
||||
var config zap.Config
|
||||
|
||||
if env == "production" {
|
||||
// FIX #25: Standardiser sur JSON en production/staging, console en développement
|
||||
if env == "production" || env == "staging" {
|
||||
config = zap.NewProductionConfig()
|
||||
// En production, utiliser JSON structuré
|
||||
// En production/staging, utiliser JSON structuré pour faciliter l'agrégation
|
||||
config.Encoding = "json"
|
||||
config.EncoderConfig = zap.NewProductionEncoderConfig()
|
||||
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
|
|
|
|||
|
|
@ -314,7 +314,8 @@ func (aw *aggregationWriter) Close() error {
|
|||
func NewLoggerWithAggregation(env, logLevel string, aggConfig *AggregationConfig) (*Logger, error) {
|
||||
var config zap.Config
|
||||
|
||||
if env == "production" {
|
||||
// FIX #25: Standardiser sur JSON en production/staging, console en développement
|
||||
if env == "production" || env == "staging" {
|
||||
config = zap.NewProductionConfig()
|
||||
config.Encoding = "json"
|
||||
config.EncoderConfig = zap.NewProductionEncoderConfig()
|
||||
|
|
|
|||
Loading…
Reference in a new issue