public function BackgroundProcess::getLog in Background Process 7.2
Get accumulated log for the process.
File
- ./
background_process.inc, line 861 - External API short overview
Class
- BackgroundProcess
- @file
Code
public function getLog() {
$original_log = $this->log;
// Get drupal messages
$messages = drupal_get_messages(NULL, TRUE);
$messages['status'] = empty($messages['status']) ? array() : $messages['status'];
$messages['warning'] = empty($messages['warning']) ? array() : $messages['warning'];
$messages['error'] = empty($messages['error']) ? array() : $messages['error'];
foreach ($messages['status'] as $message) {
$this
->log($message);
}
foreach ($messages['warning'] as $message) {
$this
->log($message, WATCHDOG_WARNING);
}
foreach ($messages['error'] as $message) {
$this
->log($message, WATCHDOG_ERROR);
}
// 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;
}
$this
->log($message, $severity);
}
$log = $this->log;
$this->log = $original_log;
return $log;
}