You are here

function monitoring_drush_result_output_table_single in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.drush.inc \monitoring_drush_result_output_table_single()

Outputs single sensor result.

Parameters

\Drupal\monitoring\Result\SensorResultInterface $result: Sensor result object.

1 call to monitoring_drush_result_output_table_single()
monitoring_drush_result_output_table in ./monitoring.drush.inc
Outputs human readable table with results.

File

./monitoring.drush.inc, line 368
Drush support for monitoring.

Code

function monitoring_drush_result_output_table_single(SensorResultInterface $result) {
  $rows[] = array(
    dt('ID'),
    $result
      ->getSensorConfig()
      ->id(),
  );
  $rows[] = array(
    dt('Label'),
    $result
      ->getSensorConfig()
      ->getLabel(),
  );
  $rows[] = array(
    dt('Status'),
    $result
      ->getStatusLabel(),
  );
  $rows[] = array(
    dt('Message'),
    $result
      ->getMessage(),
  );
  $rows[] = array(
    dt('Execution time'),
    $result
      ->getExecutionTime() . 'ms',
  );
  $rows[] = array(
    dt('Result age'),
    \Drupal::service('date.formatter')
      ->formatInterval(time() - $result
      ->getTimestamp()),
  );

  // Add the verbose output if requested.
  if ($verbose_output = $result
    ->getVerboseOutput()) {

    // @todo Improve plaintext rendering for tables(view sensor).
    $rows[] = array(
      dt('Verbose output'),
      strip_tags(\Drupal::service('renderer')
        ->renderRoot($verbose_output)),
    );
  }
  drush_print_table($rows);
}