Skip to content

Commit

Permalink
Add debugging logging to api client [MA-150]
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgarwood committed Dec 1, 2023
1 parent 9717f14 commit fe6a36e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Libraries/Api/Builders/Connection/AicConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -126,13 +128,17 @@ 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);
}
return $response;
}
$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;
Expand Down

0 comments on commit fe6a36e

Please sign in to comment.