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); } }
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); } }