You are here

protected function SensorRunner::needsLogging in Monitoring 7

Same name and namespace in other branches
  1. 8 src/SensorRunner.php \Drupal\monitoring\SensorRunner::needsLogging()

Checks if sensor results should be logged.

Parameters

\Drupal\monitoring\Result\SensorResultInterface $result: The sensor result.

string $old_status: The old sensor status.

string $new_status: Thew new sensor status.

Return value

bool TRUE if the result should be logged, FALSE if not.

1 call to SensorRunner::needsLogging()
SensorRunner::logResults in lib/Drupal/monitoring/SensorRunner.php
Log results if needed.

File

lib/Drupal/monitoring/SensorRunner.php, line 262
Contains \Drupal\monitoring\SensorRunner.

Class

SensorRunner
Instantiate and run requested sensors.

Namespace

Drupal\monitoring

Code

protected function needsLogging($result, $old_status = NULL, $new_status = NULL) {
  $log_activity = $result
    ->getSensorInfo()
    ->getSetting('result_logging', FALSE);

  // We log if requested or on status change.
  if ($this->loggingMode == 'on_request') {
    return $log_activity || $old_status != $new_status;
  }

  // We are logging all.
  if ($this->loggingMode == 'all') {
    return TRUE;
  }
  return FALSE;
}