You are here

function errorlog_watchdog in Logging and alerts 7.2

Same name and namespace in other branches
  1. 6.2 errorlog/errorlog.module \errorlog_watchdog()
  2. 6 errorlog/errorlog.module \errorlog_watchdog()
  3. 7 errorlog/errorlog.module \errorlog_watchdog()

Implements hook_watchdog().

File

errorlog/errorlog.module, line 43
Drupal Module: Web Server Logging and Alerts

Code

function errorlog_watchdog($log) {
  if (variable_get('errorlog_' . $log['severity'], FALSE)) {

    // Make sure that $log['variables'] is always an array to avoid
    // errors like in issue http://drupal.org/node/1325938
    if (!is_array($log['variables'])) {
      $log['variables'] = array();
    }

    // Send themed alert to the web server's log.
    if (drupal_get_bootstrap_phase() >= DRUPAL_BOOTSTRAP_FULL) {
      $message = theme('errorlog_format', $log);
    }
    else {
      $message = theme_errorlog_format($log);
    }
    error_log($message);
  }
}