You are here

public function UltimateCronErrorsSensorPlugin::getErrorLogEntries in Monitoring 8

Returns error log entries.

Return value

array An array of log entries.

1 call to UltimateCronErrorsSensorPlugin::getErrorLogEntries()
UltimateCronErrorsSensorPlugin::runSensor in src/Plugin/monitoring/SensorPlugin/UltimateCronErrorsSensorPlugin.php
Runs the sensor, updating $sensor_result.

File

src/Plugin/monitoring/SensorPlugin/UltimateCronErrorsSensorPlugin.php, line 72

Class

UltimateCronErrorsSensorPlugin
Monitors the ultimate cron errors.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

public function getErrorLogEntries() {

  // Loads active cron jobs.
  $job_ids = \Drupal::entityQuery('ultimate_cron_job')
    ->condition('status', TRUE)
    ->execute();
  $jobs = CronJob::loadMultiple($job_ids);
  $log_entries = [];

  /** @var \Drupal\ultimate_cron\Entity\CronJob $job */
  foreach ($jobs as $job) {
    $job_entries = $job
      ->getLogEntries(ULTIMATE_CRON_LOG_TYPE_ALL, 10);
    foreach ($job_entries as $job_entry) {
      if ($job_entry->severity == RfcLogLevel::ERROR) {
        $job_entry->job = $job;
        $log_entries[] = $job_entry;
      }
    }
  }
  return $log_entries;
}