f
This commit is contained in:
@@ -345,6 +345,43 @@ func (e *ExternalServiceLogger) LogResponseWithID(requestID, transactionID, apiC
|
||||
)
|
||||
}
|
||||
|
||||
// LogResponseWithBody 记录包含响应内容的响应日志
|
||||
func (e *ExternalServiceLogger) LogResponseWithBody(requestID, transactionID, apiCode string, statusCode int, duration time.Duration, responseBody string) {
|
||||
logger := e.responseLogger
|
||||
if logger == nil {
|
||||
logger = e.logger
|
||||
}
|
||||
logger.Info(fmt.Sprintf("%s API响应", e.serviceName),
|
||||
zap.String("service", e.serviceName),
|
||||
zap.String("request_id", requestID),
|
||||
zap.String("transaction_id", transactionID),
|
||||
zap.String("api_code", apiCode),
|
||||
zap.Int("status_code", statusCode),
|
||||
zap.Duration("duration", duration),
|
||||
zap.String("response_body", responseBody),
|
||||
zap.String("timestamp", time.Now().Format(time.RFC3339)),
|
||||
)
|
||||
}
|
||||
|
||||
// LogResponseWithIDAndBody 记录包含响应ID和响应内容的响应日志
|
||||
func (e *ExternalServiceLogger) LogResponseWithIDAndBody(requestID, transactionID, apiCode string, statusCode int, duration time.Duration, responseID string, responseBody string) {
|
||||
logger := e.responseLogger
|
||||
if logger == nil {
|
||||
logger = e.logger
|
||||
}
|
||||
logger.Info(fmt.Sprintf("%s API响应", e.serviceName),
|
||||
zap.String("service", e.serviceName),
|
||||
zap.String("request_id", requestID),
|
||||
zap.String("transaction_id", transactionID),
|
||||
zap.String("api_code", apiCode),
|
||||
zap.Int("status_code", statusCode),
|
||||
zap.Duration("duration", duration),
|
||||
zap.String("response_id", responseID),
|
||||
zap.String("response_body", responseBody),
|
||||
zap.String("timestamp", time.Now().Format(time.RFC3339)),
|
||||
)
|
||||
}
|
||||
|
||||
// LogError 记录错误日志
|
||||
func (e *ExternalServiceLogger) LogError(requestID, transactionID, apiCode string, err error, params interface{}) {
|
||||
e.logger.Error(fmt.Sprintf("%s API错误", e.serviceName),
|
||||
|
||||
Reference in New Issue
Block a user