function drush_log

8.0.x drush_log($message, $type = LogLevel::NOTICE, $error = null)
6.x drush_log($message, $type = 'notice', $error = null)
7.x drush_log($message, $type = LogLevel::NOTICE, $error = null)
3.x drush_log($message, $type = 'notice', $error = null)
4.x drush_log($message, $type = 'notice', $error = null)
5.x drush_log($message, $type = 'notice', $error = null)
master drush_log($message, $type = LogLevel::INFO, $error = null)

Add a log message to the log history.

This function calls the callback stored in the 'DRUSH_LOG_CALLBACK' context with the resulting entry at the end of execution.

This allows you to replace it with custom logging implementations if needed, such as logging to a file or logging to a database (drupal or otherwise).

The default callback is the Drush\Log\Logger class with prints the messages to the shell.


message: String containing the message to be logged.

type: The type of message to be logged. Common types are 'warning', 'error', 'success' and 'notice'. A type of 'ok' or 'success' can also be supplied to flag something that worked. If you want your log messages to print to screen without the user entering a -v or --verbose flag, use type 'ok', this prints log messages out to STDERR, which prints to screen (unless you have redirected it). All other types of messages will be assumed to be notices.

Related topics

186 calls to drush_log()
BaseBoot::bootstrap_and_dispatch in lib/Drush/Boot/BaseBoot.php
Main entrypoint to bootstrap the selected CMS and execute the selected command.
dlm in includes/
Run print_r on a variable and log the output.
DrupalBoot::bootstrap_do_drupal_site in lib/Drush/Boot/DrupalBoot.php
Called by bootstrap_drupal_site to do the main work of the drush drupal site bootstrap.
DrupalBoot::bootstrap_drupal_database in lib/Drush/Boot/DrupalBoot.php
Boostrap the Drupal database.
DrupalBoot::bootstrap_drupal_root in lib/Drush/Boot/DrupalBoot.php
Bootstrap Drush with a valid Drupal Directory.

... See full list


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


function drush_log($message, $type = LogLevel::NOTICE, $error = null) {
  $entry = array(
    'type' => $type,
    'message' => $message,
    'timestamp' => microtime(TRUE),
    'memory' => memory_get_usage(),
  $entry['error'] = $error;

  return _drush_log($entry);