From 0a716aeb91799bdeae905be743db9a56e3602a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 18 May 2014 21:17:30 +0200 Subject: [PATCH] debug mode constant option to log even suppressed errors --- application/core/ErrorHandler.php | 9 +++++---- application/core/ManiaControl.php | 1 + application/plugins/steeffeen/ObstaclePlugin.php | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index 9d365362..98d96eb2 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -19,12 +19,12 @@ class ErrorHandler { */ const MC_DEBUG_NOTICE = 'ManiaControl.DebugNotice'; const SETTING_RESTART_ON_EXCEPTION = 'Automatically restart on Exceptions'; + const LOG_SUPPRESSED_ERRORS = false; /* * Private Properties */ private $maniaControl = null; - private $reportErrors = true; /** * Construct Error Handler @@ -58,7 +58,7 @@ class ErrorHandler { $logMessage = $message . PHP_EOL . 'Class: ' . $exceptionClass . PHP_EOL . 'Trace:' . PHP_EOL . $traceString; $this->maniaControl->log($logMessage); - if ($this->reportErrors) { + if (!ManiaControl::DEBUG_MODE) { $error = array(); $error['Type'] = 'Exception'; $error['Message'] = $message; @@ -201,7 +201,8 @@ class ErrorHandler { * @return bool */ public function handleError($errorNumber, $errorString, $errorFile = null, $errorLine = -1, array $errorContext = array()) { - if (error_reporting() === 0) { + $suppressed = (error_reporting() === 0); + if ($suppressed && !self::LOG_SUPPRESSED_ERRORS) { return false; } @@ -215,7 +216,7 @@ class ErrorHandler { $logMessage = $message . PHP_EOL . 'File&Line: ' . $fileLine . PHP_EOL . 'Trace: ' . $traceString; $this->maniaControl->log($logMessage); - if ($this->reportErrors && !$this->isUserErrorNumber($errorNumber)) { + if (!ManiaControl::DEBUG_MODE && !$this->isUserErrorNumber($errorNumber) && !$suppressed) { $error = array(); $error['Type'] = 'Error'; $error['Message'] = $message; diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 9c41e8e6..89b1cda9 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -52,6 +52,7 @@ class ManiaControl implements CommandListener, TimerListener { const OS_UNIX = 'Unix'; const OS_WIN = 'Windows'; const SCRIPT_TIMEOUT = 10; + const DEBUG_MODE = false; const URL_WEBSERVICE = 'http://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; diff --git a/application/plugins/steeffeen/ObstaclePlugin.php b/application/plugins/steeffeen/ObstaclePlugin.php index 256152a6..5ff2b68b 100644 --- a/application/plugins/steeffeen/ObstaclePlugin.php +++ b/application/plugins/steeffeen/ObstaclePlugin.php @@ -39,7 +39,6 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin { * @see \ManiaControl\Plugins\Plugin::prepare() */ public static function prepare(ManiaControl $maniaControl) { - // do nothing } /**