diff --git a/extend/Ca/Ca.php b/extend/Ca/Ca.php index 851ebc9..5981289 100644 --- a/extend/Ca/Ca.php +++ b/extend/Ca/Ca.php @@ -350,6 +350,12 @@ abstract class Ca */ public function httpRequest(string $path, array $arg = []): mixed { + // 请求前日志 + Log::getInstance()->info('CA-HTTP-REQUEST-START', [ + 'url' => $path, + 'params' => $arg, + ]); + $option = [ "headers" => [ "app_id" => $this->app_id, @@ -359,10 +365,21 @@ abstract class Ca $arg = array_merge($arg, $option); + // 合并 header 后的最终请求参数日志 + Log::getInstance()->info('CA-HTTP-REQUEST-PARAMS', [ + 'url' => $path, + 'final_params' => $arg, + ]); + $response = $this->client->post($path, $arg); if ($response->getStatusCode() != '200') { // 请求失败 + Log::getInstance()->error('CA-HTTP-REQUEST-ERROR', [ + 'url' => $path, + 'status_code' => $response->getStatusCode(), + 'response' => $response->getBody()->getContents(), + ]); throw new BusinessException($response->getBody()->getContents()); } $body = json_decode($response->getBody(), true); @@ -379,6 +396,12 @@ abstract class Ca throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); } + // 请求成功日志 + Log::getInstance()->info('CA-HTTP-REQUEST-SUCCESS', [ + 'url' => $path, + 'response' => $body, + ]); + return $body['body']; }