function drush_log

8.0.x drush.inc drush_log($message, $type = LogLevel::NOTICE, $error = null)
6.x drush.inc drush_log($message, $type = 'notice', $error = null)
7.x drush.inc drush_log($message, $type = LogLevel::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)
5.x drush.inc drush_log($message, $type = 'notice', $error = null)
master drush.inc 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_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

111 calls to drush_log()
core_cli_bashrc in commands/core/core.drush.inc
dlm in includes/drush.inc
Run print_r on a variable and log the output.
drush_archive_dump in commands/core/archive.drush.inc
Command callback. Generate site archive file.
drush_archive_restore in commands/core/archive.drush.inc
Command callback. Restore web site(s) from a site archive file.
drush_bootstrap in includes/environment.inc
Bootstrap Drush to the desired phase.

... See full list

File

includes/drush.inc, line 2405
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;
  return $callback($entry);
}