Error dump

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-06 22:51:17 +01:00
parent 18bab3b045
commit 3a110bf8b6
2 changed files with 23 additions and 0 deletions

View File

@ -383,6 +383,10 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
}
return false;
}
public function getProperties(){
return $this->config;
}
public function getProperty($name){
if(isset($this->config[$name])){

View File

@ -317,11 +317,30 @@ class PocketMinecraftServer extends stdClass{
$this->loadEvents();
declare(ticks=15);
register_tick_function(array($this, "tick"));
register_shutdown_function(array($this, "dumpError"));
register_shutdown_function(array($this, "close"));
$this->trigger("server.start", microtime(true));
console("[INFO] Server started!");
$this->process();
}
public function dumpError(){
console("[ERROR] An Unrecovereable has ocurred and the server has Crashed. Creating an Error Dump");
$dump = "# PocketMine-MP Error Dump ".date("D M j H:i:s T Y")."\r\n";
$dump .= "Error: ".var_export(error_get_last(), true)."\r\n\r\n";
$version = new VersionString();
$dump .= "PM Version: ".$version." #".$version->getNumber()." [Protocol ".CURRENT_PROTOCOL."]\r\n";
$dump .= "uname -a: ".php_uname("a")."\r\n";
$dump .= "PHP Version: " .phpversion()."\r\n";
$dump .= "Zend version: ".zend_version()."\r\n";
$dump .= "OS : " .PHP_OS.", ".Utils::getOS()."\r\n";
$dump .= "Debug Info: ".var_export($this->debugInfo(false), true)."\r\n\r\n\r\n";
$dump .= "server.properties: ".var_export($this->api->getProperties(), true)."\r\n\r\n\r\n";
$dump .= "Loaded Modules: ".var_export(get_loaded_extensions(), true)."\r\n\r\n";
$name = "error_dump_".time();
logg($dump, $name, true, 0, true);
console("[ERROR] Please submit the \"logs/{$name}.log\" file to the Bug Reporting page. Give as much info as you can.", true, true, 0);
}
public function tick(){
$time = microtime(true);