You are here

function drush_acquia_purge_ap_diagnosis in Acquia Purge 7

Same name and namespace in other branches
  1. 6 acquia_purge.drush.inc \drush_acquia_purge_ap_diagnosis()

Perform a series of diagnostic self-tests.

Parameters

int $v: Optional, the level of diagnostics presented. Test results that match or are higher than the given level are returned.

2 calls to drush_acquia_purge_ap_diagnosis()
drush_acquia_purge_ap_process in ./acquia_purge.drush.inc
Purge all queued items from the command line.
drush_acquia_purge_ap_purge in ./acquia_purge.drush.inc
Purge a specified path from your balancers.

File

./acquia_purge.drush.inc, line 88
Drush integration providing common maintenance tasks.

Code

function drush_acquia_purge_ap_diagnosis($v = ACQUIA_PURGE_SEVLEVEL_INFO) {
  $oldverbosity = drush_get_context('DRUSH_VERBOSE');
  $tests = _acquia_purge_service()
    ->diagnostics()
    ->get($v);

  // Define a mapping between install.inc's requirement states and drush_log().
  $severitymap = array(
    ACQUIA_PURGE_SEVLEVEL_INFO => 'info',
    ACQUIA_PURGE_SEVLEVEL_OK => 'ok',
    ACQUIA_PURGE_SEVLEVEL_WARNING => 'warning',
    ACQUIA_PURGE_SEVLEVEL_ERROR => 'error',
  );

  // Tell Drush to be verbose.
  drush_set_context('DRUSH_VERBOSE', TRUE);
  drush_set_context('DRUSH_COLUMNS', 120);

  // Determine the longest test name and set the drush_type field.
  $longest = 25;
  foreach ($tests as $id => $test) {
    $tests[$id]['drush_type'] = $severitymap[$test['severity']];
    $len = drupal_strlen($test['name']);
    if ($len > $longest) {
      $longest = $len + 2;
    }
  }

  // Iterate the tests and call drush_log with the appropriate message type.
  foreach ($tests as $test) {
    _drush_acquia_purge_ap_diagnosis_log($test, $longest);
  }

  // Set back the old verbosity state.
  drush_set_context('DRUSH_VERBOSE', $oldverbosity);
}