mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +00:00
Merge branch 'release/3.5'
This commit is contained in:
commit
a2e4fdc8a2
@ -159,7 +159,7 @@ class CrashDump{
|
|||||||
$error = $lastExceptionError;
|
$error = $lastExceptionError;
|
||||||
}else{
|
}else{
|
||||||
$error = (array) error_get_last();
|
$error = (array) error_get_last();
|
||||||
$error["trace"] = Utils::getTrace(4); //Skipping CrashDump->baseCrash, CrashDump->construct, Server->crashDump
|
$error["trace"] = Utils::printableCurrentTrace(3); //Skipping CrashDump->baseCrash, CrashDump->construct, Server->crashDump
|
||||||
$errorConversion = [
|
$errorConversion = [
|
||||||
E_ERROR => "E_ERROR",
|
E_ERROR => "E_ERROR",
|
||||||
E_WARNING => "E_WARNING",
|
E_WARNING => "E_WARNING",
|
||||||
|
@ -2206,7 +2206,7 @@ class Server{
|
|||||||
"fullFile" => $e->getFile(),
|
"fullFile" => $e->getFile(),
|
||||||
"file" => $errfile,
|
"file" => $errfile,
|
||||||
"line" => $errline,
|
"line" => $errline,
|
||||||
"trace" => Utils::getTrace(0, $trace)
|
"trace" => Utils::printableTrace($trace)
|
||||||
];
|
];
|
||||||
|
|
||||||
global $lastExceptionError, $lastError;
|
global $lastExceptionError, $lastError;
|
||||||
|
@ -90,7 +90,7 @@ class LoginPacket extends DataPacket{
|
|||||||
|
|
||||||
$logger = \GlobalLogger::get();
|
$logger = \GlobalLogger::get();
|
||||||
$logger->debug(get_class($e) . " was thrown while decoding connection request in login (protocol version " . ($this->protocol ?? "unknown") . "): " . $e->getMessage());
|
$logger->debug(get_class($e) . " was thrown while decoding connection request in login (protocol version " . ($this->protocol ?? "unknown") . "): " . $e->getMessage());
|
||||||
foreach(Utils::getTrace(0, $e->getTrace()) as $line){
|
foreach(Utils::printableTrace($e->getTrace()) as $line){
|
||||||
$logger->debug($line);
|
$logger->debug($line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
|||||||
$errfile = Utils::cleanPath($errfile);
|
$errfile = Utils::cleanPath($errfile);
|
||||||
|
|
||||||
$message = get_class($e) . ": \"$errstr\" ($errno) in \"$errfile\" at line $errline";
|
$message = get_class($e) . ": \"$errstr\" ($errno) in \"$errfile\" at line $errline";
|
||||||
$stack = Utils::getTrace(0, $trace);
|
$stack = Utils::printableTrace($trace);
|
||||||
|
|
||||||
$this->synchronized(function() use ($type, $message, $stack) : void{
|
$this->synchronized(function() use ($type, $message, $stack) : void{
|
||||||
$this->log($type, $message);
|
$this->log($type, $message);
|
||||||
|
@ -461,24 +461,13 @@ class Utils{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $start
|
* @param array $trace
|
||||||
* @param array|null $trace
|
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getTrace($start = 0, $trace = null){
|
public static function printableTrace(array $trace) : array{
|
||||||
if($trace === null){
|
|
||||||
if(function_exists("xdebug_get_function_stack")){
|
|
||||||
$trace = array_reverse(xdebug_get_function_stack());
|
|
||||||
}else{
|
|
||||||
$e = new \Exception();
|
|
||||||
$trace = $e->getTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$messages = [];
|
$messages = [];
|
||||||
$j = 0;
|
for($i = 0; isset($trace[$i]); ++$i){
|
||||||
for($i = (int) $start; isset($trace[$i]); ++$i, ++$j){
|
|
||||||
$params = "";
|
$params = "";
|
||||||
if(isset($trace[$i]["args"]) or isset($trace[$i]["params"])){
|
if(isset($trace[$i]["args"]) or isset($trace[$i]["params"])){
|
||||||
if(isset($trace[$i]["args"])){
|
if(isset($trace[$i]["args"])){
|
||||||
@ -491,12 +480,39 @@ class Utils{
|
|||||||
return (is_object($value) ? get_class($value) . " object" : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value))));
|
return (is_object($value) ? get_class($value) . " object" : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value))));
|
||||||
}, $args));
|
}, $args));
|
||||||
}
|
}
|
||||||
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? self::cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")";
|
$messages[] = "#$i " . (isset($trace[$i]["file"]) ? self::cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $skipFrames
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function currentTrace(int $skipFrames = 0) : array{
|
||||||
|
++$skipFrames; //omit this frame from trace, in addition to other skipped frames
|
||||||
|
if(function_exists("xdebug_get_function_stack")){
|
||||||
|
$trace = array_reverse(xdebug_get_function_stack());
|
||||||
|
}else{
|
||||||
|
$e = new \Exception();
|
||||||
|
$trace = $e->getTrace();
|
||||||
|
}
|
||||||
|
for($i = 0; $i < $skipFrames; ++$i){
|
||||||
|
unset($trace[$i]);
|
||||||
|
}
|
||||||
|
return array_values($trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $skipFrames
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function printableCurrentTrace(int $skipFrames = 0) : array{
|
||||||
|
return self::printableTrace(self::currentTrace(++$skipFrames));
|
||||||
|
}
|
||||||
|
|
||||||
public static function cleanPath($path){
|
public static function cleanPath($path){
|
||||||
return str_replace(["\\", ".php", "phar://", str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH)], ["/", "", "", "", ""], $path);
|
return str_replace(["\\", ".php", "phar://", str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH)], ["/", "", "", "", ""], $path);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user