diff --git a/core/behaviors/LoggerBehavior.php b/core/behaviors/LoggerBehavior.php index 425229f..6c4f922 100644 --- a/core/behaviors/LoggerBehavior.php +++ b/core/behaviors/LoggerBehavior.php @@ -26,19 +26,21 @@ public function events() public function beforeSend($event) { $response = $event->sender; - $request = \Yii::$app->request; - $requestId = Yii::$app->requestId->id; - $code = ArrayHelper::getValue($response->data, 'code'); - $message = [ - 'request_id' => $requestId, - 'type' => $code === 0 ? 'response_data_success' : 'response_data_error', - 'header' => Json::encode($request->headers), - 'params' => $request->bodyParams, - 'url' => $request->absoluteUrl, - 'response' => Json::encode($response->data) - ]; - $response->data = ['request_id' => $requestId] + $response->data; - $code === 0 ? Yii::info($message, 'request') : Yii::error($message, 'request'); + if ($response->format != 'html') { + $request = \Yii::$app->request; + $requestId = Yii::$app->requestId->id; + $code = ArrayHelper::getValue($response->data, 'code'); + $message = [ + 'request_id' => $requestId, + 'type' => $code === 0 ? 'response_data_success' : 'response_data_error', + 'header' => Json::encode($request->headers), + 'params' => $request->bodyParams, + 'url' => $request->absoluteUrl, + 'response' => Json::encode($response->data) + ]; + $response->data = ['request_id' => $requestId] + $response->data; + $code === 0 ? Yii::info($message, 'request') : Yii::error($message, 'request'); + } } public function beforeAction()