func ECSCompatibleEncoderConfig()

in encoder_config.go [135:163]


func ECSCompatibleEncoderConfig(cfg zapcore.EncoderConfig) zapcore.EncoderConfig {
	// set the required MVP ECS keys
	cfg.MessageKey = messageKey
	cfg.LevelKey = logLevelKey
	cfg.TimeKey = timeKey
	if cfg.NameKey != "" {
		cfg.NameKey = logNameKey
	}
	// set further ECS defined keys only if keys were defined,
	// as zap omits these log attributes when keys are not defined
	// and ecszap does not intend to change this logic
	if cfg.StacktraceKey != "" {
		cfg.StacktraceKey = stackTraceKey
	}
	if cfg.CallerKey != "" {
		cfg.CallerKey = callerKey
		cfg.EncodeCaller = defaultEncodeCaller
	}
	// always set the time encoding to the ISO8601 time format
	cfg.EncodeTime = encodeTime
	// ensure all required encoders are set
	if cfg.EncodeDuration == nil {
		cfg.EncodeDuration = defaultEncodeDuration
	}
	if cfg.EncodeLevel == nil {
		cfg.EncodeLevel = defaultEncodeLevel
	}
	return cfg
}