From 206a765044ee535fe7ffde7df2ec79213e7be327 Mon Sep 17 00:00:00 2001 From: haomingming Date: Mon, 1 Dec 2025 16:20:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/Ca/Ca.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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']; }