mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 03:16:35 +00:00
CrashDump: add server uptime to crash information
This commit is contained in:
parent
135f1c95e4
commit
f0241043de
@ -47,6 +47,7 @@ use function is_resource;
|
|||||||
use function json_encode;
|
use function json_encode;
|
||||||
use function json_last_error_msg;
|
use function json_last_error_msg;
|
||||||
use function max;
|
use function max;
|
||||||
|
use function microtime;
|
||||||
use function mkdir;
|
use function mkdir;
|
||||||
use function ob_end_clean;
|
use function ob_end_clean;
|
||||||
use function ob_get_contents;
|
use function ob_get_contents;
|
||||||
@ -59,7 +60,6 @@ use function sprintf;
|
|||||||
use function str_split;
|
use function str_split;
|
||||||
use function strpos;
|
use function strpos;
|
||||||
use function substr;
|
use function substr;
|
||||||
use function time;
|
|
||||||
use function zend_version;
|
use function zend_version;
|
||||||
use function zlib_encode;
|
use function zlib_encode;
|
||||||
use const E_COMPILE_ERROR;
|
use const E_COMPILE_ERROR;
|
||||||
@ -90,7 +90,7 @@ class CrashDump{
|
|||||||
* having their content changed, version format changing, etc.
|
* having their content changed, version format changing, etc.
|
||||||
* It is not necessary to increase this when adding new fields.
|
* It is not necessary to increase this when adding new fields.
|
||||||
*/
|
*/
|
||||||
private const FORMAT_VERSION = 3;
|
private const FORMAT_VERSION = 4;
|
||||||
|
|
||||||
private const PLUGIN_INVOLVEMENT_NONE = "none";
|
private const PLUGIN_INVOLVEMENT_NONE = "none";
|
||||||
private const PLUGIN_INVOLVEMENT_DIRECT = "direct";
|
private const PLUGIN_INVOLVEMENT_DIRECT = "direct";
|
||||||
@ -100,7 +100,7 @@ class CrashDump{
|
|||||||
private $server;
|
private $server;
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $fp;
|
private $fp;
|
||||||
/** @var int */
|
/** @var float */
|
||||||
private $time;
|
private $time;
|
||||||
/**
|
/**
|
||||||
* @var mixed[]
|
* @var mixed[]
|
||||||
@ -113,12 +113,12 @@ class CrashDump{
|
|||||||
private $path;
|
private $path;
|
||||||
|
|
||||||
public function __construct(Server $server){
|
public function __construct(Server $server){
|
||||||
$this->time = time();
|
$this->time = microtime(true);
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
if(!is_dir($this->server->getDataPath() . "crashdumps")){
|
if(!is_dir($this->server->getDataPath() . "crashdumps")){
|
||||||
mkdir($this->server->getDataPath() . "crashdumps");
|
mkdir($this->server->getDataPath() . "crashdumps");
|
||||||
}
|
}
|
||||||
$this->path = $this->server->getDataPath() . "crashdumps/" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
|
$this->path = $this->server->getDataPath() . "crashdumps/" . date("D_M_j-H.i.s-T_Y", (int) $this->time) . ".log";
|
||||||
$fp = @fopen($this->path, "wb");
|
$fp = @fopen($this->path, "wb");
|
||||||
if(!is_resource($fp)){
|
if(!is_resource($fp)){
|
||||||
throw new \RuntimeException("Could not create Crash Dump");
|
throw new \RuntimeException("Could not create Crash Dump");
|
||||||
@ -126,7 +126,8 @@ class CrashDump{
|
|||||||
$this->fp = $fp;
|
$this->fp = $fp;
|
||||||
$this->data["format_version"] = self::FORMAT_VERSION;
|
$this->data["format_version"] = self::FORMAT_VERSION;
|
||||||
$this->data["time"] = $this->time;
|
$this->data["time"] = $this->time;
|
||||||
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
|
$this->data["uptime"] = $this->time - \pocketmine\START_TIME;
|
||||||
|
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", (int) $this->time));
|
||||||
$this->addLine();
|
$this->addLine();
|
||||||
$this->baseCrash();
|
$this->baseCrash();
|
||||||
$this->generalData();
|
$this->generalData();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user