improved error report

This commit is contained in:
Steffen Schröder 2014-06-15 03:37:07 +02:00
parent f6ac379dc0
commit 5e375c0c13

View File

@ -83,18 +83,26 @@ class ErrorHandler {
// Build log message // Build log message
$errorTag = $this->getErrorTag($errorNumber); $errorTag = $this->getErrorTag($errorNumber);
$userError = $this->isUserErrorNumber($errorNumber); $userError = $this->isUserErrorNumber($errorNumber);
$traceString = null;
$sourceClass = null;
$traceSourceClass = null; $traceSourceClass = null;
$fileLine = null;
$message = $errorTag . ': ' . $errorString; $message = $errorTag . ': ' . $errorString;
$fileLine = $errorFile . ': ' . $errorLine; if (!$onShutdown) {
$traceString = $this->parseBackTrace(array_slice(debug_backtrace(), 1), $traceSourceClass); $traceString = $this->parseBackTrace(array_slice(debug_backtrace(), 1), $traceSourceClass);
}
if ($errorFile) {
$fileLine = $errorFile . ': ' . $errorLine;
$sourceClass = $this->getSourceClass($errorFile); $sourceClass = $this->getSourceClass($errorFile);
if (!$sourceClass) { }
if (!$sourceClass && $traceSourceClass) {
$sourceClass = $traceSourceClass; $sourceClass = $traceSourceClass;
} }
$logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine; $logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine;
if (!$userError && !$onShutdown) { if (!$userError && $traceString) {
$logMessage .= PHP_EOL . 'Trace: ' . PHP_EOL . $traceString; $logMessage .= PHP_EOL . 'Trace: ' . PHP_EOL . $traceString;
} }
$this->maniaControl->log($logMessage); $this->maniaControl->log($logMessage);
@ -104,10 +112,14 @@ class ErrorHandler {
$report = array(); $report = array();
$report['Type'] = 'Error'; $report['Type'] = 'Error';
$report['Message'] = $message; $report['Message'] = $message;
if ($fileLine) {
$report['FileLine'] = $fileLine; $report['FileLine'] = $fileLine;
}
if ($sourceClass) {
$report['SourceClass'] = $sourceClass; $report['SourceClass'] = $sourceClass;
$report['PluginId'] = PluginManager::getPluginId($sourceClass); $report['PluginId'] = PluginManager::getPluginId($sourceClass);
if (!$onShutdown) { }
if ($traceString) {
$report['Backtrace'] = $traceString; $report['Backtrace'] = $traceString;
} }
$report['OperatingSystem'] = php_uname(); $report['OperatingSystem'] = php_uname();