bedezign\yii2\audit\panels\ErrorPanel::log PHP Method

log() public method

Log an exception
public log ( integer $entry_id, Exception | Throwable $exception ) : null | static
$entry_id integer Entry to associate the error with
$exception Exception | Throwable
return null | static
    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;
    }