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_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_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('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 base dir
|
||||||
define('ManiaControlDir', __DIR__);
|
define('ManiaControlDir', __DIR__);
|
||||||
|
@ -33,7 +33,7 @@ class ErrorHandler {
|
|||||||
*/
|
*/
|
||||||
public function exceptionHandler(\Exception $ex) {
|
public function exceptionHandler(\Exception $ex) {
|
||||||
$message = "[ManiaControl EXCEPTION]: {$ex->getMessage()}" . PHP_EOL;
|
$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;
|
$message .= "Trace: {$ex->getTraceAsString()}" . PHP_EOL;
|
||||||
logMessage($message);
|
logMessage($message);
|
||||||
|
|
||||||
@ -57,6 +57,8 @@ class ErrorHandler {
|
|||||||
|
|
||||||
if (!json_decode($success)) {
|
if (!json_decode($success)) {
|
||||||
logMessage("Exception-Report failed");
|
logMessage("Exception-Report failed");
|
||||||
|
} else {
|
||||||
|
logMessage("Exception successfully reported!");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
@ -101,11 +103,13 @@ class ErrorHandler {
|
|||||||
$success = FileUtil::loadFile($url);
|
$success = FileUtil::loadFile($url);
|
||||||
|
|
||||||
if (!json_decode($success)) {
|
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...');
|
logMessage('Stopping execution...');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -128,6 +132,15 @@ class ErrorHandler {
|
|||||||
if ($errorLevel == E_ERROR) {
|
if ($errorLevel == E_ERROR) {
|
||||||
return '[PHP 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) {
|
if ($errorLevel == E_USER_NOTICE) {
|
||||||
return '[ManiaControl NOTICE]';
|
return '[ManiaControl NOTICE]';
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,12 @@ class ManiaControl implements CommandListener {
|
|||||||
// Close the client connection
|
// Close the client connection
|
||||||
$this->client->delete($this->server->ip, $this->server->port);
|
$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!');
|
$this->log('Quitting ManiaControl!');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -284,7 +290,7 @@ class ManiaControl implements CommandListener {
|
|||||||
|
|
||||||
// Loading finished
|
// Loading finished
|
||||||
$this->log('Loading completed!');
|
$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
|
// Main loop
|
||||||
while(!$this->shutdownRequested) {
|
while(!$this->shutdownRequested) {
|
||||||
|
Loading…
Reference in New Issue
Block a user