Implemented changes requested by WebComponent

This commit is contained in:
Abel Hoogeveen 2019-02-09 20:25:49 +01:00
parent d670e9676b
commit 5a6b52f93d
No known key found for this signature in database
GPG Key ID: 96C2234920BF4292
6 changed files with 27 additions and 19 deletions

View File

@ -151,9 +151,11 @@ class Configurator
*/ */
public function addComponent(iComponent $component): Configurator public function addComponent(iComponent $component): Configurator
{ {
$this->components[] = $component; if (in_array($component, $this->components))
$component->onAddComponent($this); return $this;
$component->onAddComponent($this);
$this->components[] = $component;
return $this; return $this;
} }
@ -212,6 +214,18 @@ class Configurator
return $this; return $this;
} }
/**
* Set the template that FuzeWorks should use to parse debug logs
*
* @codeCoverageIgnore
*
* @var string Name of the template file
*/
public static function setLoggerTemplate($templateName)
{
Logger::setLoggerTemplate($templateName);
}
/** /**
* Sets the default timezone. * Sets the default timezone.
* @param string $timezone * @param string $timezone

View File

@ -43,7 +43,6 @@ use FuzeWorks\Exception\EventException;
* *
* Holds all the modules and starts the framework. Allows for starting and managing modules * Holds all the modules and starts the framework. Allows for starting and managing modules
* *
* @todo Test directory priorities in separate components
* @author TechFuze <contact@techfuze.net> * @author TechFuze <contact@techfuze.net>
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net) * @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
*/ */
@ -71,13 +70,6 @@ class Core
public static $logDir; public static $logDir;
/**
* The HTTP status code of the current request
*
* @var int $http_status_code Status code
*/
public static $http_status_code = 200;
/** /**
* Initializes the core. * Initializes the core.
* *

View File

@ -129,7 +129,6 @@ class Logger {
// Set the environment variables // Set the environment variables
self::$log_last_request = $cfg_error->get('log_last_request_to_file'); self::$log_last_request = $cfg_error->get('log_last_request_to_file');
self::$log_errors_to_file = $cfg_error->get('log_errors_to_file'); self::$log_errors_to_file = $cfg_error->get('log_errors_to_file');
self::$logger_template = $cfg_error->get('logger_template');
self::newLevel('Logger Initiated'); self::newLevel('Logger Initiated');
} }
@ -262,8 +261,9 @@ class Logger {
* Please note that most of the user-defined exceptions will be caught in the router, and handled with the error-controller. * Please note that most of the user-defined exceptions will be caught in the router, and handled with the error-controller.
* *
* @param Exception $exception The occured exception. * @param Exception $exception The occured exception.
* @param bool $haltExecution. Defaults to true
*/ */
public static function exceptionHandler($exception) public static function exceptionHandler($exception, bool $haltExecution = true)
{ {
$LOG = array('type' => 'EXCEPTION', $LOG = array('type' => 'EXCEPTION',
'message' => $exception->getMessage(), 'message' => $exception->getMessage(),
@ -274,7 +274,8 @@ class Logger {
self::$logs[] = $LOG; self::$logs[] = $LOG;
// And return a 500 because this error was fatal // And return a 500 because this error was fatal
self::haltExecution($LOG); if ($haltExecution)
self::haltExecution($LOG);
} }
/** /**
@ -573,9 +574,9 @@ class Logger {
* *
* Used for debugging timings in FuzeWorks * Used for debugging timings in FuzeWorks
* *
* @return int Time passed since FuzeWorks init * @return float Time passed since FuzeWorks init
*/ */
private static function getRelativeTime(): int private static function getRelativeTime(): float
{ {
$startTime = STARTTIME; $startTime = STARTTIME;
$time = microtime(true) - $startTime; $time = microtime(true) - $startTime;

View File

@ -133,7 +133,7 @@ class Plugins
// If a header file exists, use it // If a header file exists, use it
$file = $pluginPath . DS . $pluginFolder . DS . 'header.php'; $file = $pluginPath . DS . $pluginFolder . DS . 'header.php';
$pluginFolder = ucfirst($pluginFolder); $pluginFolder = ucfirst($pluginFolder);
$className = '\FuzeWorks\Plugins\\'.$pluginFolder.'Header'; $className = '\Application\Plugin\\'.$pluginFolder.'Header';
if (file_exists($file)) if (file_exists($file))
{ {
// Load the header file // Load the header file

View File

@ -44,6 +44,10 @@ foreach ($logs as $log) {
} elseif ($log['type'] == 'LEVEL_STOP') { } elseif ($log['type'] == 'LEVEL_STOP') {
--$layer; --$layer;
$string .= '</div>'; $string .= '</div>';
} elseif ($log['type'] == 'EXCEPTION') {
$string .= '<div style="' . ($layer == 0 ? 'padding-left: 21px;' : '') . 'font-size: 11pt; background-color:#f56954;">[' . $log['type'] . '] ' . $log['message'] . '
<span style="float: right">' . (!empty($log['logFile']) ? $log['logFile'] : '') . ' : ' . (!empty($log['logLine']) ? $log['logLine'] : '') . '(' . round($log['runtime'] * 1000, 4) . ' ms)</span></div>';
$string .= '<div style="' . ($layer == 0 ? 'padding-left: 21px;' : '') . 'font-size: 11pt; background-color:#f56954;">' . (!empty($log['context']) && is_string($log['context']) ? '<u>[' . $log['context'] . ']</u>' : '') . '</div>';
} elseif ($log['type'] == 'ERROR') { } elseif ($log['type'] == 'ERROR') {
$string .= '<div style="' . ($layer == 0 ? 'padding-left: 21px;' : '') . 'font-size: 11pt; background-color:#f56954;">[' . $log['type'] . ']' . (!empty($log['context']) && is_string($log['context']) ? '<u>[' . $log['context'] . ']</u>' : '') . ' ' . $log['message'] . ' $string .= '<div style="' . ($layer == 0 ? 'padding-left: 21px;' : '') . 'font-size: 11pt; background-color:#f56954;">[' . $log['type'] . ']' . (!empty($log['context']) && is_string($log['context']) ? '<u>[' . $log['context'] . ']</u>' : '') . ' ' . $log['message'] . '
<span style="float: right">' . (!empty($log['logFile']) ? $log['logFile'] : '') . ' : ' . (!empty($log['logLine']) ? $log['logLine'] : '') . '(' . round($log['runtime'] * 1000, 4) . ' ms)</span></div>'; <span style="float: right">' . (!empty($log['logFile']) ? $log['logFile'] : '') . ' : ' . (!empty($log['logLine']) ? $log['logLine'] : '') . '(' . round($log['runtime'] * 1000, 4) . ' ms)</span></div>';

View File

@ -63,9 +63,6 @@ abstract class CoreTestAbstract extends TestCase
// Re-enable events, in case they have been disabled // Re-enable events, in case they have been disabled
Events::enable(); Events::enable();
// Reset the HTTP status code
Core::$http_status_code = 200;
// Remove Config overrides // Remove Config overrides
Config::$configOverrides = []; Config::$configOverrides = [];
} }