function system_watchdog

8.0.x drupal.inc system_watchdog($log_entry)
6.x drupal.inc system_watchdog($log_entry)
7.x drupal.inc system_watchdog($log_entry)
3.x drush.inc system_watchdog($log_entry)
4.x drush.inc system_watchdog($log_entry)
5.x drupal.inc system_watchdog($log_entry)
master drupal.inc system_watchdog($log_entry)

Log Drupal watchdog() calls.

A sneaky implementation of hook_watchdog().

1 call to system_watchdog()
1 string reference to 'system_watchdog'

File

includes/drupal.inc, line 74
Utility functions related to Drupal.

Code

function system_watchdog($log_entry) {
  // Transform non informative severity levels to 'error' for compatibility with _drush_print_log.
  // Other severity levels are coincident with the ones we use in drush.
  if (drush_drupal_major_version() >= 6 && $log_entry['severity'] <= 2) {
    $severity = 'error';
  }
  else {
    drush_include_engine('drupal', 'environment');
    $levels = core_watchdog_severity_levels();
    $severity = $levels[$log_entry['severity']];
  }
  // Format the message.
  if (is_array($log_entry['variables'])) {
    $message = strtr($log_entry['message'], $log_entry['variables']);
  }
  else {
    $message = $log_entry['message'];
  }

  // decode_entities() only loaded after FULL bootstrap.
  if (function_exists('decode_entities')) {
    $message = decode_entities($message);
  }
  $message = strip_tags($message);

  // Log or print or ignore. Just printing saves memory but thats rarely needed.
  switch (drush_get_option('watchdog', 'log')) {
    case 'log':
      drush_log('WD ' . $log_entry['type'] . ': ' . $message, $severity);
      break;
    case 'print':
      // Disable in backend mode since it logs output and the goal is to conserve memory.
      // @see _drush_bootstrap_drush().
      if (ob_get_length() === FALSE) {
        drush_print('WD ' . $severity . ' ' . $log_entry['type'] . ': ' . $message);
      }
      break;
    default:
      // Do nothing.
  }
}