public function log($entry_id, $exception)
{
// Only log each exception once
$exceptionId = spl_object_hash($exception);
if (in_array($exceptionId, $this->_exceptions)) {
return true;
}
// If this is a follow up exception, make sure to log the base exception first
if ($exception->getPrevious()) {
$this->log($entry_id, $exception->getPrevious());
}
$error = new AuditError();
$error->entry_id = $entry_id;
$error->message = $exception->getMessage();
$error->code = $exception->getCode();
$error->file = $exception->getFile();
$error->line = $exception->getLine();
$error->trace = Helper::cleanupTrace($exception->getTrace());
$error->hash = Helper::hash($error->message . $error->file . $error->line);
$this->_exceptions[] = $exceptionId;
return $error->save(false) ? $error : null;
}