You are here

private function SpiController::getWatchdogData in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getWatchdogData()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getWatchdogData()

Get the latest (last hour) critical and emergency warnings from watchdog.

These errors are 'severity' 0 and 2.

Return value

array EMERGENCY and CRITICAL watchdog records for last hour.

1 call to SpiController::getWatchdogData()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 445

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getWatchdogData() {
  $wd = [];
  if ($this
    ->moduleHandler()
    ->moduleExists('dblog')) {

    // phpcs:disable
    $result = Database::getConnection()
      ->select('watchdog', 'w')
      ->fields('w', [
      'wid',
      'severity',
      'type',
      'message',
      'timestamp',
    ])
      ->condition('w.severity', [
      RfcLogLevel::EMERGENCY,
      RfcLogLevel::CRITICAL,
    ], 'IN')
      ->condition('w.timestamp', \Drupal::time()
      ->getRequestTime() - 3600, '>')
      ->execute();

    // phpcs:enable
    while ($record = $result
      ->fetchAssoc()) {
      $wd[$record['severity']] = $record;
    }
  }
  return $wd;
}