function drush_backend_output

8.0.x backend.inc drush_backend_output()
6.x backend.inc drush_backend_output()
7.x backend.inc drush_backend_output()
3.x backend.inc drush_backend_output()
4.x backend.inc drush_backend_output()
5.x backend.inc drush_backend_output()
master backend.inc drush_backend_output()

Print the json-encoded output of this command, including the encoded log records, context information, etc.

2 calls to drush_backend_output()
drush_shutdown in includes/preflight.inc
Shutdown function for use while Drush and Drupal are bootstrapping and to return any registered errors.
drush_unit_batch in tests/unit.drush.inc
Command callback.

File

includes/backend.inc, line 137
Drush backend API

Code

function drush_backend_output() {
  $data = array();

  if (drush_get_context('DRUSH_PIPE')) {
    $pipe = drush_get_context('DRUSH_PIPE_BUFFER');
    $data['output'] = $pipe; // print_r($pipe, TRUE);
  }
  else {
    // Strip out backend commands.
    $packet_regex = strtr(sprintf(DRUSH_BACKEND_PACKET_PATTERN, "([^\0]*)"), array("\0" => "\\0"));
    $packet_regex = str_replace("\n", "", $packet_regex);
    $data['output'] = preg_replace("/$packet_regex/s", '', drush_backend_output_collect(NULL));
  }

  if (drush_get_context('DRUSH_QUIET', FALSE)) {
    ob_end_clean();
  }

  $result_object = drush_backend_get_result();
  if (isset($result_object)) {
    $data['object'] = $result_object;
  }

  $error = drush_get_error();
  $data['error_status'] = ($error) ? $error : DRUSH_SUCCESS;

  $data['log'] = drush_get_log(); // Append logging information
  // The error log is a more specific version of the log, and may be used by calling
  // scripts to check for specific errors that have occurred.
  $data['error_log'] = drush_get_error_log();
  // If there is a @self record, then include it in the result
  $self_record = drush_sitealias_get_record('@self');
  if (!empty($self_record)) {
    $site_context = drush_get_context('site', array());
    unset($site_context['config-file']);
    unset($site_context['context-path']);
    unset($self_record['loaded-config']);
    unset($self_record['#name']);
    $data['self'] = array_merge($site_context, $self_record);
  }

  // Return the options that were set at the end of the process.
  $data['context'] = drush_get_merged_options();
  printf("\0" . DRUSH_BACKEND_OUTPUT_DELIMITER, json_encode($data));
}