Compare commits

..

No commits in common. "master" and "1.2.0-DEV" have entirely different histories.

4 changed files with 67 additions and 50 deletions

View File

@ -1,7 +1,7 @@
FuzeWorks - Readme FuzeWorks - Readme
=================== ===================
Version 1.3.0 Version 1.2.0
A versatile PHP Framework built to perform. A versatile PHP Framework built to perform.

View File

@ -1,18 +1,25 @@
{ {
"name": "fuzeworks/tracycomponent", "name": "fuzeworks/tracycomponent",
"description": "FuzeWorks Framework Tracy Debugger Component", "description": "FuzeWorks Framework Tracy Debugger Component",
"homepage": "https://i15.nl/fuzeworks", "homepage": "https://techfuze.net/fuzeworks",
"license": ["MIT"], "license": ["MIT"],
"authors": [ "authors": [
{ {
"name": "Abel Hoogeveen", "name": "TechFuze",
"homepage": "https://i15.nl" "homepage": "https://techfuze.net"
},
{
"name": "FuzeWorks Community",
"homepage": "https://techfuze.net/fuzeworks/contributors"
} }
], ],
"require": { "require": {
"php": ">=7.4.0", "php": ">=7.1.0",
"tracy/tracy": "2.8.*", "tracy/tracy": "2.5.*",
"fuzeworks/core": "~1.3.0" "fuzeworks/core": "dev-development"
},
"require-dev": {
"phpunit/phpunit": "^7"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -35,7 +35,6 @@
*/ */
namespace FuzeWorks; namespace FuzeWorks;
use FuzeWorks\Exception\EventException;
use FuzeWorks\Exception\InvalidArgumentException; use FuzeWorks\Exception\InvalidArgumentException;
use Tracy\Debugger; use Tracy\Debugger;
@ -58,14 +57,7 @@ class TracyComponent implements iComponent
* *
* @var bool $enableTracy * @var bool $enableTracy
*/ */
protected static $enableTracy = true; protected $enableTracy = true;
/**
* Set to true after tracy has been started
*
* @var bool $enabled
*/
protected static $enabled = false;
public function getName(): string public function getName(): string
{ {
@ -83,52 +75,34 @@ class TracyComponent implements iComponent
* Enables Tracy when requested to do so. Disables FuzeWorks Logger. * Enables Tracy when requested to do so. Disables FuzeWorks Logger.
* *
* @param Factory $container * @param Factory $container
* @throws EventException * @throws Exception\EventException
*/ */
public function onCreateContainer(Factory $container) public function onCreateContainer(Factory $container)
{ {
// If Tracy should not be enabled, escape // If Tracy should not be enabled, escape
if (self::$enableTracy == false) if ($this->enableTracy == false)
{ {
Logger::logInfo("TracyComponent added but not enabled."); Logger::logInfo("TracyComponent added but not enabled.");
return; return;
} }
// Disable screenLog
Events::addListener(function($event){
$event->setCancelled(true);
}, 'screenLogEvent');
// Enable Tracy. Use DEVELOPMENT mode when logger is enabled // Enable Tracy. Use DEVELOPMENT mode when logger is enabled
$debuggerEnabled = $container->logger->isEnabled(); if ($container->logger->isEnabled() == true)
if ($debuggerEnabled)
Debugger::enable(Debugger::DEVELOPMENT, realpath(Core::$logDir)); Debugger::enable(Debugger::DEVELOPMENT, realpath(Core::$logDir));
else else
Debugger::enable(Debugger::PRODUCTION, realpath(Core::$logDir)); Debugger::enable(Debugger::PRODUCTION, realpath(Core::$logDir));
// Disable FuzeWorks Logger // Disable FuzeWorks Logger
Logger::disableScreenLog(); $container->logger->disable();
// Reset exception handlers
set_error_handler(array('\FuzeWorks\Core', 'errorHandler'), E_ALL);
set_exception_handler(array('\FuzeWorks\Core', 'exceptionHandler'));
// Register exception handler
Core::addErrorHandler(['\Tracy\Debugger', 'errorHandler'], Priority::LOW);
// Tracy has an annoying default error 500 page.
// This page will be suppressed when in production mode.
if ($debuggerEnabled)
{
Core::addExceptionHandler(['\Tracy\Debugger', 'exceptionHandler'], Priority::LOW);
}
else
Core::addExceptionHandler([$this, 'exceptionHandler'], Priority::LOW);
// Enable bridges // Enable bridges
GitTracyBridge::register(); GitTracyBridge::register();
LoggerTracyBridge::register(); LoggerTracyBridge::register();
self::$enabled = true;
}
public function exceptionHandler($exception, $exit = true)
{
Debugger::getLogger()->log($exception, \Tracy\Logger::EXCEPTION);
} }
/** /**
@ -182,9 +156,9 @@ class TracyComponent implements iComponent
* *
* Has no effect after container is created * Has no effect after container is created
*/ */
public static function enableTracy() public function enableTracy()
{ {
self::$enableTracy = true; $this->enableTracy = true;
} }
/** /**
@ -192,9 +166,9 @@ class TracyComponent implements iComponent
* *
* Has no effect after container is created * Has no effect after container is created
*/ */
public static function disableTracy() public function disableTracy()
{ {
self::$enableTracy = false; $this->enableTracy = false;
} }
/** /**
@ -202,8 +176,8 @@ class TracyComponent implements iComponent
* *
* @return bool * @return bool
*/ */
public static function isEnabled(): bool public function isEnabled(): bool
{ {
return self::$enabled; return $this->enableTracy;
} }
} }

View File

@ -35,12 +35,48 @@
*/ */
?> ?>
<style class="tracy-debug"> <style class="tracy-debug">
</style> </style>
<div class="fuzeworks-LoggerPanel"> <div class="fuzeworks-LoggerPanel">
<h1> Logger</h1> <h1> Logger</h1>
<div class="tracy-inner"> <div class="tracy-inner">
<?php \FuzeWorks\Logger::logToScreen(); ?> <table>
<thead>
<tr>
<th>#</th>
<th>Type</th>
<th>Message</th>
<th>File</th>
<th>Line</th>
<th>Timing</th>
</tr>
</thead>
<tbody>
<?php foreach ($logs as $key => $log): ?>
<?php if ($log['type'] === 'LEVEL_STOP')
{
continue;
}
elseif ($log['type'] === 'LEVEL_START')
{
$log['type'] = 'CINFO';
}
?>
<tr class="<?php echo($log['type']); ?>">
<td><?php echo( htmlspecialchars($key)); ?></td>
<td><?php echo( htmlspecialchars ($log['type'])); ?></td>
<td><?php echo( htmlspecialchars ($log['message'])); ?></td>
<td><?php echo( empty($log['logFile']) ? 'x' : htmlspecialchars ($log['logFile'])); ?></td>
<td><?php echo( empty($log['logLine']) ? 'x' : htmlspecialchars ($log['logLine'])); ?></td>
<td><?php echo(round($log['runtime'] * 1000, 4)); ?> ms</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div> </div>
</div> </div>