コード例 #1
0
ファイル: CrashDump.php プロジェクト: ecoron/MinionsLandPE
 private function baseCrash()
 {
     global $lastExceptionError, $lastError;
     if (isset($lastExceptionError)) {
         $error = $lastExceptionError;
     } else {
         $error = (array) error_get_last();
         $error["trace"] = @getTrace(3);
         $errorConversion = [E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED"];
         $error["fullFile"] = $error["file"];
         $error["file"] = cleanPath($error["file"]);
         $error["type"] = isset($errorConversion[$error["type"]]) ? $errorConversion[$error["type"]] : $error["type"];
         if (($pos = strpos($error["message"], "\n")) !== false) {
             $error["message"] = substr($error["message"], 0, $pos);
         }
     }
     if (isset($lastError)) {
         $this->data["lastError"] = $lastError;
     }
     $this->data["error"] = $error;
     unset($this->data["error"]["fullFile"]);
     unset($this->data["error"]["trace"]);
     $this->addLine("Error: " . $error["message"]);
     $this->addLine("File: " . $error["file"]);
     $this->addLine("Line: " . $error["line"]);
     $this->addLine("Type: " . $error["type"]);
     if (strpos($error["file"], "src/pocketmine/") === false and strpos($error["file"], "src/raklib/") === false and file_exists($error["fullFile"])) {
         $this->addLine();
         $this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
         $this->data["plugin"] = true;
         $reflection = new \ReflectionClass(PluginBase::class);
         $file = $reflection->getProperty("file");
         $file->setAccessible(true);
         foreach ($this->server->getPluginManager()->getPlugins() as $plugin) {
             $filePath = \pocketmine\cleanPath($file->getValue($plugin));
             if (strpos($error["file"], $filePath) === 0) {
                 $this->data["plugin"] = $plugin->getName();
                 $this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
                 break;
             }
         }
     } else {
         $this->data["plugin"] = false;
     }
     $this->addLine();
     $this->addLine("Code:");
     $this->data["code"] = [];
     if ($this->server->getProperty("auto-report.send-code", true) !== false) {
         $file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
         for ($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l) {
             $this->addLine("[" . ($l + 1) . "] " . @$file[$l]);
             $this->data["code"][$l + 1] = @$file[$l];
         }
     }
     $this->addLine();
     $this->addLine("Backtrace:");
     foreach ($this->data["trace"] = $error["trace"] as $line) {
         $this->addLine($line);
     }
     $this->addLine();
 }
コード例 #2
0
ファイル: MainLogger.php プロジェクト: TylerAndrew/ClearSky
 public function logException(\Exception $e, $trace = null)
 {
     if ($trace === null) {
         $trace = $e->getTrace();
     }
     $errstr = $e->getMessage();
     $errfile = $e->getFile();
     $errno = $e->getCode();
     $errline = $e->getLine();
     $errorConversion = [0 => "EXCEPTION", E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED"];
     if ($errno === 0) {
         $type = LogLevel::CRITICAL;
     } else {
         $type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
     }
     $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
     if (($pos = strpos($errstr, "\n")) !== false) {
         $errstr = substr($errstr, 0, $pos);
     }
     $errfile = \pocketmine\cleanPath($errfile);
     $this->log($type, get_class($e) . ": \"{$errstr}\" ({$errno}) in \"{$errfile}\" at line {$errline}");
     foreach (@\pocketmine\getTrace(1, $trace) as $i => $line) {
         $this->debug($line);
     }
 }
コード例 #3
0
 public function logException(\Throwable $e, $trace = null)
 {
     if ($trace === null) {
         $trace = $e->getTrace();
     }
     $errstr = $e->getMessage();
     $errfile = $e->getFile();
     $errno = $e->getCode();
     $errline = $e->getLine();
     $errorConversion = [0 => "例外", E_ERROR => "重大", E_WARNING => "警告", E_PARSE => "構成エラー", E_NOTICE => "エラーの可能性", E_CORE_ERROR => "システムエラー", E_CORE_WARNING => "システム警告", E_COMPILE_ERROR => "コンパイルエラー", E_COMPILE_WARNING => "構成への警告", E_USER_ERROR => "ユーザ側へのエラー", E_USER_WARNING => "ユーザ側への警告", E_USER_NOTICE => "ユーザに問題", E_STRICT => "互換性のエラー", E_RECOVERABLE_ERROR => "致命的エラー", E_DEPRECATED => "コードの警告", E_USER_DEPRECATED => "ユーザ側の警告"];
     if ($errno === 0) {
         $type = LogLevel::CRITICAL;
     } else {
         $type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE);
     }
     $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
     if (($pos = strpos($errstr, "\n")) !== false) {
         $errstr = substr($errstr, 0, $pos);
     }
     $errfile = \pocketmine\cleanPath($errfile);
     $this->log($type, get_class($e) . ": \"{$errstr}\" ({$errno}) in \"{$errfile}\" at line {$errline}");
     foreach (@\pocketmine\getTrace(1, $trace) as $i => $line) {
         $this->debug($line);
     }
 }