Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fe370c3e4 | |||
4d74474327 | |||
c5a19353d5 | |||
d88c7fccd5 | |||
a060d8bb66 | |||
4dd45c56fd | |||
bb6fa39d90 | |||
5a37bdce2a | |||
5d11627f47 |
@ -1,7 +1,7 @@
|
||||
FuzeWorks - Readme
|
||||
===================
|
||||
|
||||
Version 1.2.0
|
||||
Version 1.3.0
|
||||
|
||||
A versatile PHP Framework built to perform.
|
||||
|
||||
|
@ -1,25 +1,18 @@
|
||||
{
|
||||
"name": "fuzeworks/tracycomponent",
|
||||
"description": "FuzeWorks Framework Tracy Debugger Component",
|
||||
"homepage": "https://techfuze.net/fuzeworks",
|
||||
"homepage": "https://i15.nl/fuzeworks",
|
||||
"license": ["MIT"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "TechFuze",
|
||||
"homepage": "https://techfuze.net"
|
||||
},
|
||||
{
|
||||
"name": "FuzeWorks Community",
|
||||
"homepage": "https://techfuze.net/fuzeworks/contributors"
|
||||
"name": "Abel Hoogeveen",
|
||||
"homepage": "https://i15.nl"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.0",
|
||||
"tracy/tracy": "2.5.*",
|
||||
"fuzeworks/core": "dev-development"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7"
|
||||
"php": ">=7.4.0",
|
||||
"tracy/tracy": "2.8.*",
|
||||
"fuzeworks/core": "~1.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
namespace FuzeWorks;
|
||||
use FuzeWorks\Exception\EventException;
|
||||
use FuzeWorks\Exception\InvalidArgumentException;
|
||||
use Tracy\Debugger;
|
||||
|
||||
@ -57,7 +58,14 @@ class TracyComponent implements iComponent
|
||||
*
|
||||
* @var bool $enableTracy
|
||||
*/
|
||||
protected $enableTracy = true;
|
||||
protected static $enableTracy = true;
|
||||
|
||||
/**
|
||||
* Set to true after tracy has been started
|
||||
*
|
||||
* @var bool $enabled
|
||||
*/
|
||||
protected static $enabled = false;
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
@ -75,34 +83,52 @@ class TracyComponent implements iComponent
|
||||
* Enables Tracy when requested to do so. Disables FuzeWorks Logger.
|
||||
*
|
||||
* @param Factory $container
|
||||
* @throws Exception\EventException
|
||||
* @throws EventException
|
||||
*/
|
||||
public function onCreateContainer(Factory $container)
|
||||
{
|
||||
// If Tracy should not be enabled, escape
|
||||
if ($this->enableTracy == false)
|
||||
if (self::$enableTracy == false)
|
||||
{
|
||||
Logger::logInfo("TracyComponent added but not enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable screenLog
|
||||
Events::addListener(function($event){
|
||||
$event->setCancelled(true);
|
||||
}, 'screenLogEvent');
|
||||
|
||||
// Enable Tracy. Use DEVELOPMENT mode when logger is enabled
|
||||
if ($container->logger->isEnabled() == true)
|
||||
$debuggerEnabled = $container->logger->isEnabled();
|
||||
if ($debuggerEnabled)
|
||||
Debugger::enable(Debugger::DEVELOPMENT, realpath(Core::$logDir));
|
||||
else
|
||||
Debugger::enable(Debugger::PRODUCTION, realpath(Core::$logDir));
|
||||
|
||||
// Disable FuzeWorks Logger
|
||||
$container->logger->disable();
|
||||
Logger::disableScreenLog();
|
||||
|
||||
// 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
|
||||
GitTracyBridge::register();
|
||||
LoggerTracyBridge::register();
|
||||
self::$enabled = true;
|
||||
}
|
||||
|
||||
public function exceptionHandler($exception, $exit = true)
|
||||
{
|
||||
Debugger::getLogger()->log($exception, \Tracy\Logger::EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,9 +182,9 @@ class TracyComponent implements iComponent
|
||||
*
|
||||
* Has no effect after container is created
|
||||
*/
|
||||
public function enableTracy()
|
||||
public static function enableTracy()
|
||||
{
|
||||
$this->enableTracy = true;
|
||||
self::$enableTracy = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,9 +192,9 @@ class TracyComponent implements iComponent
|
||||
*
|
||||
* Has no effect after container is created
|
||||
*/
|
||||
public function disableTracy()
|
||||
public static function disableTracy()
|
||||
{
|
||||
$this->enableTracy = false;
|
||||
self::$enableTracy = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,8 +202,8 @@ class TracyComponent implements iComponent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
public static function isEnabled(): bool
|
||||
{
|
||||
return $this->enableTracy;
|
||||
return self::$enabled;
|
||||
}
|
||||
}
|
@ -35,48 +35,12 @@
|
||||
*/
|
||||
?>
|
||||
<style class="tracy-debug">
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<div class="fuzeworks-LoggerPanel">
|
||||
<h1> Logger</h1>
|
||||
|
||||
<div class="tracy-inner">
|
||||
<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>
|
||||
<?php \FuzeWorks\Logger::logToScreen(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user