You are here

public function WatchdogLogger::catchMessagesShutdown in Ultimate Cron 8.2

Shutdown function callback for a single log entry.

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

Parameters

LogEntry $log_entry: The log entry to close.

1 call to WatchdogLogger::catchMessagesShutdown()
WatchdogLogger::catchMessagesShutdownWrapper in src/Logger/WatchdogLogger.php
Shutdown handler wrapper for catching messages.

File

src/Logger/WatchdogLogger.php, line 121

Class

WatchdogLogger
Logs events in currently running cronjobs.

Namespace

Drupal\ultimate_cron\Logger

Code

public function catchMessagesShutdown(LogEntry $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 = RfcLogLevel::INFO;
    if ($error['type'] && (E_NOTICE || E_USER_NOTICE || E_USER_WARNING)) {
      $severity = RfcLogLevel::NOTICE;
    }
    if ($error['type'] && (E_WARNING || E_CORE_WARNING || E_USER_WARNING)) {
      $severity = RfcLogLevel::WARNING;
    }
    if ($error['type'] && (E_ERROR || E_CORE_ERROR || E_USER_ERROR || E_RECOVERABLE_ERROR)) {
      $severity = RfcLogLevel::ERROR;
    }
    $log_entry
      ->log($message, NULL, $severity);
  }
  $log_entry
    ->finish();
}