From fe6a36eeb7353a6d5c2f82a8236508ebc1b0d049 Mon Sep 17 00:00:00 2001 From: Zach Garwood Date: Fri, 1 Dec 2023 11:56:17 -0600 Subject: [PATCH] Add debugging logging to api client [MA-150] --- app/Libraries/Api/Builders/Connection/AicConnection.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Libraries/Api/Builders/Connection/AicConnection.php b/app/Libraries/Api/Builders/Connection/AicConnection.php index c9440e40..0964a7d1 100644 --- a/app/Libraries/Api/Builders/Connection/AicConnection.php +++ b/app/Libraries/Api/Builders/Connection/AicConnection.php @@ -103,6 +103,7 @@ public function execute($endpoint = null, $params = []) if (config('api.logger')) { \Log::info($verb . ' ' . $endpoint); \Log::info(print_r($options, true)); + $responseTimerStart = microtime(true); } // Perform API request and caching @@ -114,6 +115,7 @@ public function execute($endpoint = null, $params = []) if ($decacheHash && config('api.cache_buster') && $decacheHash === config('api.cache_buster')) { \Cache::forget($cacheKey); + \Log::warning('cache busted'); } // Use default TTL if no explicit has been defined @@ -126,6 +128,9 @@ public function execute($endpoint = null, $params = []) } return $response; }); + if (config('api.logger')) { + \Log::info('response time = ' . microtime(true) - $responseTimerStart . ' seconds'); + } if (isset($response->status) && $response->status != 200) { \Cache::forget($cacheKey); } @@ -133,6 +138,7 @@ public function execute($endpoint = null, $params = []) } $response = $this->client->request($verb, $endpoint, $options); if (config('api.logger')) { + \Log::info('response time = ' . microtime(true) - $responseTimerStart . ' seconds'); \Log::info((array) $response->body); } return $response;