function drush_log

6.x drush.inc drush_log($message, $type = 'notice', $error = null)
5.x drush.inc drush_log($message, $type = 'notice', $error = null)
3.x drush.inc drush_log($message, $type = 'notice', $error = null)
4.x drush.inc drush_log($message, $type = 'notice', $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_print_log() function with prints the messages to the shell.

Parameters

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 'failed' can also be supplied to flag as an 'error'. A type of 'ok' or 'completed' can also be supplied to flag as a 'success' All other types of messages will be assumed to be notices.

Related topics

138 calls to drush_log()
dlm in includes/drush.inc
Run print_r on a variable and log the output.
DrushBatchContext::offsetSet in includes/batch.inc
DrushMakeProject::applyPatches in commands/make/make.project.inc
Retrieve and apply any patches specified by the makefile to this project.
DrushMakeProject::getTranslations in commands/make/make.project.inc
Retrieve translations for this project.
DrushMakeProject::make in commands/make/make.project.inc
Build a project.

... See full list

File

includes/drush.inc, line 1489
The drush API implementation and helpers.

Code

function drush_log($message, $type = 'notice', $error = null) {
  $log = &drush_get_context('DRUSH_LOG', array());
  $callback = drush_get_context('DRUSH_LOG_CALLBACK', '_drush_print_log');
  $entry = array(
    'type' => $type,
    'message' => $message,
    'timestamp' => microtime(TRUE),
    'memory' => memory_get_usage(),
  );
  $entry['error'] = $error;
  $log[] = $entry;
  drush_backend_packet('log', $entry);

  return $callback($entry);
}