You are here

public function UltimateCronLogger::catchMessagesShutdown in Ultimate Cron 7.2

PHP shutdown function callback.

Ensures that a log entry has been closed properly on shutdown.

Parameters

UltimateCronLogEntry $log_entry: The log entry to close.

File

./ultimate_cron.plugin.inc, line 1284
Plugin framework for Ultimate Cron.

Class

UltimateCronLogger
Abstract class for Ultimate Cron loggers.

Code

public function catchMessagesShutdown($log_entry) {
  $this
    ->unCatchMessages($log_entry);
  if ($log_entry->finished) {
    return;
  }

  // Get error messages.
  $error = error_get_last();
  if ($error) {
    $message = $error['message'] . ' (line ' . $error['line'] . ' of ' . $error['file'] . ').' . "\n";
    $severity = WATCHDOG_INFO;
    if ($error['type'] && (E_NOTICE || E_USER_NOTICE || E_USER_WARNING)) {
      $severity = WATCHDOG_NOTICE;
    }
    if ($error['type'] && (E_WARNING || E_CORE_WARNING || E_USER_WARNING)) {
      $severity = WATCHDOG_WARNING;
    }
    if ($error['type'] && (E_ERROR || E_CORE_ERROR || E_USER_ERROR || E_RECOVERABLE_ERROR)) {
      $severity = WATCHDOG_ERROR;
    }
    $log_entry
      ->log($log_entry->name, $message, array(), $severity);
  }
  $log_entry
    ->finish();
}