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' or 'notice', 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 info.

Related topics

180 calls to drush_log()
dlm in includes/
Run print_r on a variable and log the output.
DrupalBoot8::bootstrap_drupal_full in lib/Drush/Boot/DrupalBoot8.php
Attempt to load the full Drupal system.
DrupalKernel::addServiceModifier in lib/Drush/Drupal/DrupalKernel.php
Add a service modifier to the container builder.
DrupalKernel::createFromRequest in lib/Drush/Drupal/DrupalKernel.php
DrupalKernel::getContainerBuilder in lib/Drush/Drupal/DrupalKernel.php

... See full list


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


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

  return _drush_log($entry);