Implemented a new bar object which contains the FuzeWorks Logger.
This way the logger is not shown prominently on the screen anymore.
This commit is contained in:
parent
099409bc1f
commit
7b406d864d
|
@ -91,8 +91,19 @@ class Events
|
|||
*/
|
||||
public static function addListener($callback, $eventName, $priority = EventPriority::NORMAL)
|
||||
{
|
||||
// Perform multiple checks
|
||||
if (EventPriority::getPriority($priority) == false) {
|
||||
throw new EventException('Unknown priority '.$priority);
|
||||
throw new EventException('Can not add listener: Unknown priority '.$priority, 1);
|
||||
}
|
||||
|
||||
if (!is_callable($callback))
|
||||
{
|
||||
throw new EventException("Can not add listener: Callback is not callable", 1);
|
||||
}
|
||||
|
||||
if (empty($eventName))
|
||||
{
|
||||
throw new EventException("Can not add listener: No eventname provided", 1);
|
||||
}
|
||||
|
||||
if (!isset(self::$listeners[$eventName])) {
|
||||
|
|
|
@ -142,6 +142,11 @@ class Logger {
|
|||
self::$log_to_file = Config::get('error')->log_to_file;
|
||||
self::$logger_template = Config::get('error')->logger_template;
|
||||
self::newLevel('Logger Initiated');
|
||||
|
||||
if (self::$useTracy)
|
||||
{
|
||||
LoggerTracy::register();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace FuzeWorks;
|
||||
use Tracy\IBarPanel;
|
||||
use Tracy\Debugger;
|
||||
|
||||
/**
|
||||
* LoggerTracy Class.
|
||||
*
|
||||
* This class provides a bridge between FuzeWorks\Logger and Tracy Debugging tool.
|
||||
*
|
||||
* This class registers in Tracy, and creates a Bar object which contains the log.
|
||||
* Afterwards it blocks a screen log so that the content is not shown on the screen as well.
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class LoggerTracy implements IBarPanel {
|
||||
|
||||
/**
|
||||
* Register the bar and register the event which will block the screen log
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
$class = new self();
|
||||
Events::addListener(array($class, 'screenLogEventListener'), 'screenLogEvent', EventPriority::NORMAL);
|
||||
$bar = Debugger::getBar();
|
||||
$bar->addPanel($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener that blocks the screen log
|
||||
*
|
||||
* @param Event
|
||||
* @return Event
|
||||
*/
|
||||
public function screenLogEventListener($event)
|
||||
{
|
||||
$event->setCancelled(true);
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function getTab()
|
||||
{
|
||||
ob_start(function () {});
|
||||
require dirname(__DIR__) . '/views/view.tracyloggertab.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
public function getPanel()
|
||||
{
|
||||
ob_start(function () {});
|
||||
$logs = Logger::$Logs;
|
||||
require dirname(__DIR__) . '/views/view.tracyloggerpanel.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<style class="tracy-debug">
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel table {
|
||||
font: 9pt/1.5 Consolas, monospace;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel .error td {
|
||||
background: #FF3300 !important;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel .warning td {
|
||||
background: #FFFF66 !important;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel .debug td {
|
||||
background: #33CC33 !important;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel .info td {
|
||||
background: #BDE678 !important;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel .cinfo td {
|
||||
background: #BDE622 !important;
|
||||
}
|
||||
|
||||
#tracy-debug .fuzeworks-LoggerPanel pre, #tracy-debug .fuzeworks-LoggerPanel code {
|
||||
display: inline;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="fuzeworks-LoggerPanel">
|
||||
<h1> FuzeWorks - Logger</h1>
|
||||
|
||||
<div class="tracy-inner">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Message</th>
|
||||
<th>File</th>
|
||||
<th>Line</th>
|
||||
<th>Timing</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($logs as $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 ($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>
|
|
@ -0,0 +1,6 @@
|
|||
<span title="Logger">
|
||||
<svg viewBox="0 0 2048 2048">
|
||||
<path d="M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z" fill-opacity=".9" fill="#BDE797"/>
|
||||
</svg>
|
||||
<span class="tracy-label">Logger</span>
|
||||
</span>
|
Loading…
Reference in New Issue