send fatal errors
This commit is contained in:
parent
d7c26d04ae
commit
859c57e111
@ -5,6 +5,7 @@
|
||||
define('LOG_WRITE_CURRENT_FILE', 'ManiaControl.log'); // Write current log to extra file in base dir
|
||||
define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder
|
||||
define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
|
||||
define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR);
|
||||
|
||||
// Define base dir
|
||||
define('ManiaControlDir', __DIR__);
|
||||
|
@ -33,7 +33,7 @@ class ErrorHandler {
|
||||
*/
|
||||
public function exceptionHandler(\Exception $ex) {
|
||||
$message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}" . PHP_EOL;
|
||||
$message .= "Class: ". get_class($ex) . PHP_EOL;
|
||||
$message .= "Class: " . get_class($ex) . PHP_EOL;
|
||||
$message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL;
|
||||
logMessage($message);
|
||||
|
||||
@ -57,6 +57,8 @@ class ErrorHandler {
|
||||
|
||||
if (!json_decode($success)) {
|
||||
logMessage("Exception-Report failed");
|
||||
} else {
|
||||
logMessage("Exception successfully reported!");
|
||||
}
|
||||
|
||||
exit();
|
||||
@ -101,11 +103,13 @@ class ErrorHandler {
|
||||
$success = FileUtil::loadFile($url);
|
||||
|
||||
if (!json_decode($success)) {
|
||||
logMessage("Error-Report failed");
|
||||
logMessage("Error-Report failed!");
|
||||
} else {
|
||||
logMessage("Error successfully reported!");
|
||||
}
|
||||
}
|
||||
|
||||
if ($errorNumber == E_ERROR || $errorNumber == E_USER_ERROR) {
|
||||
if ($errorNumber == E_ERROR || $errorNumber == E_USER_ERROR || $errorNumber == E_FATAL) {
|
||||
logMessage('Stopping execution...');
|
||||
exit();
|
||||
}
|
||||
@ -128,6 +132,15 @@ class ErrorHandler {
|
||||
if ($errorLevel == E_ERROR) {
|
||||
return '[PHP ERROR]';
|
||||
}
|
||||
if ($errorLevel == E_CORE_ERROR) {
|
||||
return '[PHP CORE ERROR]';
|
||||
}
|
||||
if ($errorLevel == E_COMPILE_ERROR) {
|
||||
return '[PHP COMPILE ERROR]';
|
||||
}
|
||||
if ($errorLevel == E_RECOVERABLE_ERROR) {
|
||||
return '[PHP RECOVERABLE ERROR]';
|
||||
}
|
||||
if ($errorLevel == E_USER_NOTICE) {
|
||||
return '[ManiaControl NOTICE]';
|
||||
}
|
||||
|
@ -219,10 +219,16 @@ class ManiaControl implements CommandListener {
|
||||
$this->client->sendHideManialinkPage();
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
|
||||
// Close the client connection
|
||||
$this->client->delete($this->server->ip, $this->server->port);
|
||||
|
||||
//Check and Trigger Fatal Errors
|
||||
$error = error_get_last();
|
||||
if ($error && ($error['type'] & E_FATAL)) {
|
||||
$this->errorHandler->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
|
||||
}
|
||||
|
||||
$this->log('Quitting ManiaControl!');
|
||||
exit();
|
||||
}
|
||||
@ -284,7 +290,7 @@ class ManiaControl implements CommandListener {
|
||||
|
||||
// Loading finished
|
||||
$this->log('Loading completed!');
|
||||
$this->log('Link: maniaplanet://#join=' . $this->server->login .'@' . $this->server->titleId);
|
||||
$this->log('Link: maniaplanet://#join=' . $this->server->login . '@' . $this->server->titleId);
|
||||
|
||||
// Main loop
|
||||
while(!$this->shutdownRequested) {
|
||||
|
@ -214,7 +214,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
|
||||
$requiredRecords = 3;
|
||||
|
||||
$query = 'SELECT playerIndex, COUNT(*) AS Cnt
|
||||
$query = 'SELECT playerIndex, COUNT(*) AS Cnt
|
||||
FROM ' . LocalRecordsPlugin::TABLE_RECORDS . '
|
||||
GROUP BY PlayerIndex
|
||||
HAVING Cnt >=' . $requiredRecords;
|
||||
|
Loading…
Reference in New Issue
Block a user