function drush_print

8.0.x output.inc drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)
6.x output.inc drush_print($message = '', $indent = , $handle = NULL, $newline = TRUE)
7.x output.inc drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)
3.x drush.inc drush_print($message = '', $indent = 0)
master output.inc drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)

Prints a message with optional indentation. In general, drush_log($message, LogLevel::OK) is often a better choice than this function. That gets your confirmation message (for example) into the logs for this drush request. Consider that drush requests may be executed remotely and non interactively.

Parameters

$message: The message to print.

$indent: The indentation (space chars)

$handle: File handle to write to. NULL will write to standard output, STDERR will write to the standard error. See http://php.net/manual/en/features.commandline.io-streams.php

$newline: Add a "\n" to the end of the output. Defaults to TRUE.

Related topics

58 calls to drush_print()
DrupliconCommands::druplicon in lib/Drush/CommandFiles/core/DrupliconCommands.php
Print druplicon as post-command output.
DrushOutputAdapter::doWrite in lib/Drush/Command/DrushOutputAdapter.php
drush_choice in includes/drush.inc
Ask the user to select an item from a list. From a provided associative array, drush_choice will display all of the questions, numbered from 1 to N, and return the item the user selected. "0" is always cancel; entering a blank line is also…
drush_config_import in commands/core/config.drush.inc
Command callback. Import from specified config directory (defaults to sync).
drush_confirm in includes/drush.inc
Asks the user a basic yes/no question.

... See full list

File

includes/output.inc, line 28

Code

function drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE) {
  $msg = str_repeat(' ', $indent) . (string) $message;
  if ($newline) {
    $msg .= "\n";
  }
  if (($charset = drush_get_option('output_charset')) && function_exists('iconv')) {
    $msg = iconv('UTF-8', $charset, $msg);
  }
  if (isset($handle)) {
    fwrite($handle, $msg);
  }
  else {
    print $msg;
    //$output = \Drush::service('output');
    //$output->write($msg);
  }
}