$log = $logName? Logger::getCommon($logName) : null;
...
if($log) {
$log->log(
$url . "\n" .
(count($headers) ? ('Headers: ' . print_r($headers, true) . "\n") : '') .
(count($params) ? ('Params: ' . print_r($params, true)) : '')
);
}
$curl = curl_init();
...
$response = curl_exec($curl);
$curlInfo = curl_getinfo($curl);
...
if($log) {
$log->log($curlInfo['http_code'] . '(' . curl_error($curl) . "):\n" .
(str_starts_with($curlInfo['content_type'], 'application/json')? $response : 'non-json answer (' . $curlInfo['content_type'] . ')') . "\n");
}