function _drush_backend_integrate

8.0.x backend.inc _drush_backend_integrate($data, $backend_options, $outputted)
6.x backend.inc _drush_backend_integrate($data, $backend_options, $outputted)
7.x backend.inc _drush_backend_integrate($data, $backend_options, $outputted)
3.x backend.inc _drush_backend_integrate($data)
4.x backend.inc _drush_backend_integrate($data)
5.x backend.inc _drush_backend_integrate($data, $backend_options, $outputted)
master backend.inc _drush_backend_integrate($data, $backend_options, $outputted)

Integrate log messages and error statuses into the current process.

Output produced by the called script will be printed if we didn't print it on the fly, errors will be set, and log messages will be logged locally, if not already logged.

Parameters

data: The associative array returned from the external command.

outputted: Whether output has already been handled.

1 call to _drush_backend_integrate()
drush_backend_parse_output in includes/backend.inc
Parse output returned from a Drush command.

File

includes/backend.inc, line 280
Drush backend API

Code

function _drush_backend_integrate($data, $backend_options, $outputted) {
  // In 'integrate' mode, logs and errors have already been handled
  // by drush_backend_packet (sender) drush_backend_parse_packets (receiver - us)
  // during incremental output.  We therefore do not need to call drush_set_error
  // or drush_log here.  The exception is if the sender is an older version of
  // Drush (version 4.x) that does not send backend packets, then we will
  // not have processed the log entries yet, and must print them here.
  $received_packets = drush_get_context('DRUSH_RECEIVED_BACKEND_PACKETS', FALSE);
  if (is_array($data['log']) && $backend_options['log'] && (!$received_packets)) {
    foreach ($data['log'] as $log) {
      $message = is_array($log['message']) ? implode("\n", $log['message']) : $log['message'];
      if (isset($backend_options['#output-label'])) {
        $message = $backend_options['#output-label'] . $message;
      }
      if (isset($log['error']) && $backend_options['integrate']) {
        drush_set_error($log['error'], $message);
      }
      elseif ($backend_options['integrate']) {
        drush_log($message, $log['type']);
      }
    }
  }
  // Output will either be printed, or buffered to the drush_backend_output command.
  // If the output has already been printed, then we do not need to show it again on a failure.
  if (!$outputted) {
    if (drush_cmp_error('DRUSH_APPLICATION_ERROR') && !empty($data['output'])) {
      drush_set_error("DRUSH_APPLICATION_ERROR", dt("Output from failed command :\n !output", array('!output' => $data['output'])));
    }
    elseif ($backend_options['output']) {
      _drush_backend_print_output($data['output'], $backend_options);
    }
  }
}