You are here

public function WSDataService::__destruct in Web Service Data 8

File

src/WSDataService.php, line 44

Class

WSDataService
Service for processing WSData requests.

Namespace

Drupal\wsdata

Code

public function __destruct() {
  if ($this->performance['calls'] > 0 and $this->state
    ->get('wsdata_performance_log', 0)) {
    $message = $this
      ->t('WSData Performance - %calls calls in %runtime seconds.', [
      '%calls' => $this->performance['calls'],
      '%runtime' => round($this->performance['runtime'], 3),
    ]);
    $message .= "<br>\nCall list:\n<ol>\n";
    foreach ($this->performance['log'] as $log) {
      $method = '';
      if (isset($method)) {
        $method = ':' . $log['method'];
      }
      $message .= '<li>' . $log['wscall'] . $method . ' - ' . round($log['runtime'], 3) . "s (" . $log['cached'] . ")</li>\n";
    }
    $message .= '</ol>';
    $this->logger
      ->get('wsdata')
      ->debug($message);
  }
}