From 39d2982cf16a94dae0c61b5d2c1c0b5488816924 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Wed, 29 Apr 2015 17:49:33 +0200 Subject: [PATCH] Added more documentation and implemented the Logger::backtrace into fatal errors --- Core/System/class.config.php | 4 ++-- Core/System/class.core.php | 7 +++++-- Core/System/class.events.php | 12 ++++++++++-- Core/System/class.layout.php | 8 ++++++++ Core/System/class.logger.php | 16 +++++++++++++++- Core/System/class.models.php | 6 ++++++ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Core/System/class.config.php b/Core/System/class.config.php index 540285b..f16d69b 100644 --- a/Core/System/class.config.php +++ b/Core/System/class.config.php @@ -4,9 +4,9 @@ namespace FuzeWorks; use \Exception; /** - * Config Module + * Config Class * - * This class gives access to the config files. Allows for reading and editting + * This class gives access to the config files. Can read and write .php files with an array in a file */ class Config extends Bus{ diff --git a/Core/System/class.core.php b/Core/System/class.core.php index be4bff2..5d40ed3 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -9,8 +9,11 @@ if (!defined('FUZESYSPATH')) { define( 'FUZESYSPATH', dirname(__FILE__) . '/' ); } -// NotifierEvent, base event -// Framework +/** + * FuzeWorks Core + * + * Holds all the modules and starts the framework. Allows for starting and managing modules + */ class Core { public $mods; diff --git a/Core/System/class.events.php b/Core/System/class.events.php index 53bd4ba..18e3212 100644 --- a/Core/System/class.events.php +++ b/Core/System/class.events.php @@ -8,8 +8,16 @@ namespace FuzeWorks; use \Exception; /** - * @name Events -*/ + * Event Class + * + * Controls FuzeWorks Events. Events are classes that get loaded during special moments in the program. + * These Event objects get send to so-called 'listeners', which can modify the event object, and eventually return them to invoker. + * Typically an event process goes like this: + * - Event get's called + * - Event object is created + * - Event object is send to all listeners in order of EventPriority + * - Event is returned + */ class Events extends Bus{ private $listeners; diff --git a/Core/System/class.layout.php b/Core/System/class.layout.php index 0539d6e..3f942a3 100644 --- a/Core/System/class.layout.php +++ b/Core/System/class.layout.php @@ -3,6 +3,14 @@ namespace FuzeWorks; use \Exception; +/** + * Layout Class + * + * The Layout class is a wrapper for the Smarty Template engine. Smarty loads .tpl files and variables, and converts them to HTML. + * See the Smarty documentation for more information + * This class typically loads files from Application/Views unless specified otherwise. + * + */ class Layout extends Bus { private $Smarty = array(); diff --git a/Core/System/class.logger.php b/Core/System/class.logger.php index 0feb59f..479b1f2 100644 --- a/Core/System/class.logger.php +++ b/Core/System/class.logger.php @@ -3,6 +3,12 @@ namespace FuzeWorks; use \Exception; +/** + * Logger Class + * + * The main tool to handle errors and exceptions. Provides some tools for debugging and tracking where errors take place + * All fatal errors get catched by this class and get displayed if configured to do so. + */ class Logger extends Bus{ public $infoErrors = array(); @@ -40,6 +46,7 @@ class Logger extends Bus{ // Log it! $this->errorHandler($errno, $errstr, $errfile, $errline); + $this->logInfo($this->backtrace()); } if ($this->mods->config->error->debug == true || $this->print_to_screen) { @@ -91,6 +98,13 @@ class Logger extends Bus{ } public function logToScreen() { + // Send a screenLogEvent, allows for new screen log designs + $event = $this->mods->events->fireEvent('screenLogEvent'); + if ($event->isCancelled()) { + return false; + } + + // Otherwise just load it echo '

FuzeWorks debug log

'; $layer = 0; for($i = 0; $i < count($this->Logs); $i++){ @@ -131,7 +145,7 @@ class Logger extends Bus{ $result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering } - return "\t" . implode("
", $result); + return "BACKTRACE:
\t" . implode("
", $result)."
"; } /* =========================================LOGGING METHODS==============================================================*/ diff --git a/Core/System/class.models.php b/Core/System/class.models.php index 0386e00..2e093e8 100644 --- a/Core/System/class.models.php +++ b/Core/System/class.models.php @@ -5,6 +5,12 @@ namespace FuzeWorks; +/** + * Models Class + * + * Simple loader class for MVC Models. Typically loads models from Application/Models unless otherwise specified. + * If a model is not found, it will load a DatabaseModel type which will analyze the database and can directly be used. + */ class Models extends Bus{ private $models_array = array();