function _drush_print_log

6.x _drush_print_log($entry)
3.x _drush_print_log($entry)
4.x _drush_print_log($entry)
5.x _drush_print_log($entry)
master _drush_print_log($entry)

Display the log message

By default, only warnings and errors will be displayed, if 'verbose' is specified, it will also display notices.


The associative array for the entry.:

Return value

False in case of an error or failed type, True in all other cases.

Related topics

1 string reference to '_drush_print_log'
drush_log in includes/
Add a log message to the log history.


includes/, line 2462
The drush API implementation and helpers.


function _drush_print_log($entry) {
  if (drush_get_context('DRUSH_NOCOLOR')) {
    $red = "[%s]";
    $yellow = "[%s]";
    $green = "[%s]";
  else {
    $red = "\033[31;40m\033[1m[%s]\033[0m";
    $yellow = "\033[1;33;40m\033[1m[%s]\033[0m";
    $green = "\033[1;32;40m\033[1m[%s]\033[0m";

  $verbose = drush_get_context('DRUSH_VERBOSE');
  $debug = drush_get_context('DRUSH_DEBUG');

  $return = TRUE;
  switch ($entry['type']) {
    case 'warning':
    case 'cancel':
      $type_msg = sprintf($yellow, $entry['type']);
    case 'failed':
    case 'error':
      $type_msg = sprintf($red, $entry['type']);
      $return = FALSE;
    case 'ok':
    case 'completed':
    case 'success':
    case 'status':
      $type_msg = sprintf($green, $entry['type']);
    case 'notice':
    case 'message':
    case 'info':
      if (!$verbose) {
        // print nothing. exit cleanly.
        return TRUE;
      $type_msg = sprintf("[%s]", $entry['type']);
    default :
      if (!$debug) {
        // print nothing. exit cleanly.
        return TRUE;
      $type_msg = sprintf("[%s]", $entry['type']);

  // When running in backend mode, log messages are not displayed, as they will
  // be returned in the JSON encoded associative array.  In quiet mode, we
  // just drop log messages.
  if (drush_get_context('DRUSH_BACKEND') || drush_get_context('DRUSH_QUIET')) {
    return $return;

  $columns = drush_get_context('DRUSH_COLUMNS', 80);

  $width[1] = 11;
  // Append timer and memory values.
  if ($debug) {
    $timer = sprintf('[%s sec, %s]', round($entry['timestamp'] -DRUSH_REQUEST_TIME, 2), drush_format_size($entry['memory']));
    $entry['message'] = $entry['message'] . ' ' . $timer;

  $width[0] = ($columns - 11);

  $format = sprintf("%%-%ds%%%ds", $width[0], $width[1]);

  // Place the status message right aligned with the top line of the error message.
  $message = wordwrap($entry['message'], $width[0]);
  $lines = explode("\n", $message);
  $lines[0] = sprintf($format, $lines[0], $type_msg);
  $message = implode("\n", $lines);
  drush_print($message, 0, STDERR);
  return $return;