public function delete(SS_HTTPRequest $request) { $hash = $_REQUEST['hash']; $error = Error::get()->filter('Hash', $hash)->first(); if ($error) { $error->delete(); } foreach (ErrorOccurance::get()->filter('Hash', $hash) as $errorOccurance) { /* @var $errorOccurance ErrorOccurance */ $errorOccurance->delete(); } return $this->redirect('dev/logs'); }
protected function _write($event) { // parse event $file = $event['message']['errfile']; $line = $event['message']['errline']; $message = $event['message']['errstr']; $data = print_r($event, true); $stack = ''; foreach ($event['message']['errcontext'] as $stackPart) { if (isset($stackPart['file']) && isset($stackPart['line'])) { $stack .= $stackPart['file'] . '#' . $stackPart['line'] . PHP_EOL; } } // error unique-ness $hash = Error::generateHash($file, $line); // get/create error $error = Error::get()->filter('Hash', $hash)->limit(1); if ($error->exists()) { $error = $error->first(); $error->write(); } else { $error = new Error(); $error->Hash = $hash; $error->write(); } // create occurance $errorOccurance = new ErrorOccurance(); $errorOccurance->Hash = $hash; $errorOccurance->Message = $message; $errorOccurance->Stack = $stack; $errorOccurance->File = $file; $errorOccurance->Line = $line; $errorOccurance->IP = $_SERVER['REMOTE_ADDR']; $errorOccurance->RequestMethod = $_SERVER['REQUEST_METHOD']; $errorOccurance->RequestURI = $_SERVER['REQUEST_URI']; $errorOccurance->Data = $data; $errorOccurance->write(); }
/** * @return int */ public function NumOccurances() { return ErrorOccurance::get()->filter('Hash', $this->Hash)->count(); }