Esempio n. 1
0
 public function init()
 {
     $grav = Grav::instance();
     /** @var Config $config */
     $config = $grav['config'];
     $mode = $config->get('system.debugger.mode');
     TracyDebugger::$logDirectory = $config->get('system.debugger.log.enabled') ? LOG_DIR : null;
     TracyDebugger::$maxDepth = $config->get('system.debugger.max_depth');
     // Switch debugger into development mode if configured
     if ($config->get('system.debugger.enabled')) {
         if ($config->get('system.debugger.strict')) {
             TracyDebugger::$strictMode = true;
         }
         if (function_exists('ini_set')) {
             ini_set('display_errors', true);
         }
         if ($mode == strtolower('detect')) {
             TracyDebugger::$productionMode = self::DETECT;
         } elseif ($mode == strtolower('production')) {
             TracyDebugger::$productionMode = self::PRODUCTION;
         } else {
             TracyDebugger::$productionMode = self::DEVELOPMENT;
         }
     }
 }
Esempio n. 2
0
 public function __construct($options = [], Application $app = null, RepositoryContract $config = null, Dispatcher $dispatcher = null)
 {
     static::$options = $config !== null ? array_merge($options, $config->get('tracy')) : $options;
     TracyDebugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     TracyDebugger::$maxDepth = array_get(static::$options, 'maxDepth');
     TracyDebugger::$maxLen = array_get(static::$options, 'maxLen');
     TracyDebugger::$showLocation = array_get(static::$options, 'showLocation');
     TracyDebugger::$strictMode = array_get(static::$options, 'strictMode');
     TracyDebugger::$editor = array_get(static::$options, 'editor');
     $bar = TracyDebugger::getBar();
     foreach (array_get(static::$options, 'panels') as $key => $enabled) {
         if ($enabled === true) {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             if (class_exists($class) === false) {
                 $class = $key;
             }
             $this->panels[$key] = new $class($app, static::$options);
             $bar->addPanel($this->panels[$key], $class);
         }
     }
     if ($dispatcher !== null) {
         $dispatcher->listen('kernel.handled', function ($request, $response) {
             return static::appendDebugbar($request, $response);
         });
     } else {
         TracyDebugger::enable();
     }
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $event)
 {
     /**
      * @var ModuleOptions $moduleOptions
      */
     $moduleOptions = $event->getTarget()->getServiceManager()->get('LemoTracy\\Options\\ModuleOptions');
     if (true === $moduleOptions->getEnabled()) {
         if (null !== $moduleOptions->getMode()) {
             Debugger::enable($moduleOptions->getMode());
         }
         if (null !== $moduleOptions->getLogDirectory()) {
             Debugger::$logDirectory = $moduleOptions->getLogDirectory();
         }
         if (null !== $moduleOptions->getLogSeverity()) {
             Debugger::$logSeverity = $moduleOptions->getLogSeverity();
         }
         if (null !== $moduleOptions->getMaxDepth()) {
             Debugger::$maxDepth = $moduleOptions->getMaxDepth();
         }
         if (null !== $moduleOptions->getMaxLen()) {
             Debugger::$maxLen = $moduleOptions->getMaxLen();
         }
         if (null !== $moduleOptions->getShowBar()) {
             Debugger::$showBar = $moduleOptions->getShowBar();
         }
         if (null !== $moduleOptions->getStrict()) {
             Debugger::$strictMode = $moduleOptions->getStrict();
         }
     }
 }
Esempio n. 4
0
/**
 * LeonardoCA\Tools\ProcessMonitor detail dump
 *
 * @param string $msg
 * @param null   $data
 * @param null   $dataDescription
 * @param int    $maxDepth
 * @return void
 */
function pmd($msg = 'Detail Info', $data = null, $dataDescription = null, $maxDepth = 2)
{
    $backupDepth = Debugger::$maxDepth;
    Debugger::$maxDepth = $maxDepth;
    ProcessMonitor::dump("<em style='color:#339'>{$msg}</em>", $data, null, ProcessMonitor::SHOW_DETAIL, $dataDescription);
    Debugger::$maxDepth = $backupDepth;
}
Esempio n. 5
0
/**
 * Dump rendered Html element or code and intended output generated by tidy and optional also Html element structure
 *
 * @param Html|string $htmlElement        Html element or string
 * @param bool        $onlyReturn         output in string and don't send it to output?
 * @param int         $maxDepth           for Debugger::Dump output - to see how is the Html element built
 * @param bool        $includePrettyPrint along javascript code for prettyPrint activation?
 * @return string     Html output
 */
function dumpHtml($htmlElement, $onlyReturn = false, $maxDepth = 0, $includePrettyPrint = false)
{
    $maxDepthBackup = Debugger::$maxDepth;
    $maxLenBackup = Debugger::$maxLen;
    $showLocationBackup = Debugger::$showLocation;
    Debugger::$maxDepth = $maxDepth;
    Debugger::$maxLen = 200000;
    Debugger::$showLocation = false;
    // convert to string only once - important for Scaffolding Renderer output
    $renderedElement = (string) $htmlElement;
    $output = '<div class="rendered-element">' . $renderedElement . '</div>';
    $output .= '<pre class="prettyprint linenums pre-scrollable">' . htmlspecialchars(tidyFormatString($renderedElement)) . '</pre>';
    if ($includePrettyPrint) {
        $output .= '<script>prettyPrint();</script>';
    }
    if ($maxDepth > 0 && $htmlElement instanceof \Latte\Runtime\Html) {
        Debugger::dump($renderedElement);
        Debugger::dump($htmlElement);
    }
    Debugger::$maxDepth = $maxDepthBackup;
    Debugger::$maxLen = $maxLenBackup;
    Debugger::$showLocation = $showLocationBackup;
    if (!$onlyReturn) {
        echo $output;
    }
    return $output;
}
Esempio n. 6
0
/**
 * @param     $var
 * @param int $depth
 *
 * @return mixed
 */
function og_dump($var = NULL, $depth = 12)
{
    \Tracy\Debugger::$maxDepth = $depth;
    $args = func_get_args();
    Util::array_forget(func_num_args() - 1, $args);
    $dumper = defined('PHPUNIT_TESTS__') ? 'Tracy\\Dumper::toTerminal' : 'Tracy\\Debugger::dump';
    array_map($dumper, $args);
    return $var;
}
Esempio n. 7
0
 /**
  * initializeTracyDebuger.
  *
  * @method initializeTracyDebuger
  *
  * @param array $config
  */
 protected function initializeTracyDebuger($config)
 {
     Debugger::$editor = Arr::get($config, 'editor', Debugger::$editor);
     Debugger::$maxDepth = Arr::get($config, 'maxDepth', Debugger::$maxDepth);
     Debugger::$maxLength = Arr::get($config, 'maxLength', Debugger::$maxLength);
     Debugger::$scream = Arr::get($config, 'scream', true);
     Debugger::$showLocation = Arr::get($config, 'showLocation', true);
     Debugger::$strictMode = Arr::get($config, 'strictMode', true);
     Debugger::$time = Arr::get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     Debugger::$editorMapping = Arr::get($config, 'editorMapping', []);
 }
Esempio n. 8
0
 /**
  * Setup Tracy\Debugger with options
  *
  * @param MvcEvent $e
  * @return void
  */
 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $config = $app->getConfig();
     if (empty($config['tracy_debug']) || empty($config['tracy_debug']['enabled'])) {
         return;
     }
     array_key_exists('mode', $config['tracy_debug']) or $config['tracy_debug']['mode'] = NULL;
     array_key_exists('log', $config['tracy_debug']) or $config['tracy_debug']['log'] = NULL;
     array_key_exists('email', $config['tracy_debug']) or $config['tracy_debug']['email'] = NULL;
     Debugger::enable($config['tracy_debug']['mode'], $config['tracy_debug']['log'], $config['tracy_debug']['email']);
     !array_key_exists('strict', $config['tracy_debug']) or Debugger::$strictMode = $config['tracy_debug']['strict'];
     !array_key_exists('max_depth', $config['tracy_debug']) or Debugger::$maxDepth = $config['tracy_debug']['max_depth'];
     !array_key_exists('max_len', $config['tracy_debug']) or Debugger::$maxLen = $config['tracy_debug']['max_len'];
 }
 protected function registerDebugger()
 {
     $config = $this->app['config']['tracy'];
     Debugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     Debugger::$maxDepth = array_get($config, 'maxDepth');
     Debugger::$maxLen = array_get($config, 'maxLen');
     Debugger::$showLocation = array_get($config, 'showLocation');
     Debugger::$strictMode = array_get($config, 'strictMode');
     Debugger::$editor = array_get($config, 'editor');
     $bar = Debugger::getBar();
     foreach ($config['panels'] as $key => $enabled) {
         if ($enabled === true or $enabled === '1') {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             $bar->addPanel(new $class($config, $this->app), $class);
         } elseif (is_string($enabled) === true) {
             $class = $enabled;
             $bar->addPanel(new $class($config, $this->app), $class);
         }
     }
 }
Esempio n. 10
0
 /**
  * @param Container $app
  *
  * @return mixed
  *
  * @throws DependencyInstanceNotFound
  */
 public function register(Container $app)
 {
     /** @var Application $app */
     $config = $this->config;
     // this service provider will quietly fail if Tracy is not installed.
     if (class_exists('\\Tracy\\Debugger') and $config->get('logging.tracy.enabled')) {
         // use the environment to configure the Debugger
         $env = env('APP_ENV') === 'PRODUCTION' ? Debugger::PRODUCTION : Debugger::DEVELOPMENT;
         Debugger::$maxDepth = $config->get('logging.tracy.maxDepth', 6);
         Debugger::enable($env, rtrim($config->get('logging.logPath', LOGS), '/'));
         Debugger::$showLocation = env('DEBUG') and $config->get('logging.tracy.showLocation', FALSE);
         Debugger::$strictMode = $config->get('logging.tracy.strictMode', FALSE);
         Debugger::$showBar = FALSE;
         # env('DEBUG');
         // use the Tracy Debugger for logging.
         $app['tracy'] = Debugger::getLogger();
         $app['nine.logger'] = function ($app) {
             return $app['tracy'];
         };
     }
 }
Esempio n. 11
0
<?php

/**
 * @package Og
 * @version 0.1.0
 * @author  Greg Truesdell <*****@*****.**>
 */
use Og\Forge;
use Og\Support\Util;
use Tracy\Debugger;
use Tracy\FireLogger;
Debugger::$maxDepth = 6;
Debugger::enable(Debugger::DEVELOPMENT, LOCAL_LOGS);
Debugger::$showLocation = TRUE;
$logger = Debugger::getLogger();
Forge::getInstance()->instance(['logger', FireLogger::class], $logger);
/**
 * @param bool $raw
 *
 * @return string
 */
function elapsed_time_since_request($raw = FALSE)
{
    return !$raw ? sprintf("%8.1f ms", (microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000) : (microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000;
}
/**
 * @param $index
 *
 * @return string
 */
function location_from_backtrace($index = 2)
Esempio n. 12
0
 * Edde is self-hosted; it is proof-of-concept or it can be used as tutorial. Many experimental features
 * are implemented here.
 */
use Edde\Api\Application\IApplication;
use Edde\Ext\Neon\NeonFile;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\ConfigurationEvent;
use Edde\Runtime\Bootstrap\Event\SetupEvent;
use Edde\Runtime\Bootstrap\Event\StartupEvent;
use Tracy\Debugger;
require_once __DIR__ . '/../lib/tracy.phar';
require_once __DIR__ . '/../../src/loader.php';
BootstrapManager::bootstrap(function (ConfigurationEvent $configurationEvent) {
    $configurationEvent->getConfiguration()->addResource(new NeonFile(__DIR__ . '/../config/config.neon'))->addResource(new NeonFile(__DIR__ . '/../config/config.local.neon'), false);
}, function (SetupEvent $setupEvent) {
    $configuration = $setupEvent->getConfiguration();
    if ($configuration->isDevelMode()) {
        Debugger::enable(Debugger::DEVELOPMENT, $configuration->getDir('log'));
        Debugger::$strictMode = true;
        Debugger::$maxDepth = 12;
        Debugger::$maxLen = 8196;
    }
}, function (StartupEvent $startupEvent) {
    /**
     * optional - create (by default Edde's implementation) IApplication and run it; it holds whole life-cycle
     */
    $startupEvent->getContext()->create(IApplication::class)->run();
});
/**
 * and thats all; look around, there is many things to explore :)
 */
Esempio n. 13
0
 /**
  * Inicialização do Framework.
  * Método chamado para inicializar os atributos da classe Manager e registrar os AutoloadPaths.
  * @param string $configFile Arquivo de configuração do Maestro
  * @param string $basePath Diretório onde o Maestro está instalado
  * @param string $app Aplicação a ser executada.
  */
 public static function init()
 {
     $debug = self::getConf('maestro.debug.enabled');
     if ($debug) {
         $mode = self::getConf('maestro.options.mode') == 'DEV' ? Tracy\Debugger::DEVELOPMENT : Tracy\Debugger::PRODUCTION;
         Tracy\Debugger::enable($mode, self::$maestroPath . DIRECTORY_SEPARATOR . 'log');
         Tracy\Debugger::$logSeverity = self::getConf('maestro.debug.severity');
         Tracy\Debugger::$strictMode = self::getConf('maestro.debug.strictMode');
         Tracy\Debugger::$maxDepth = self::getConf('maestro.debug.maxDepth');
         // default: 3
         Tracy\Debugger::$maxLen = self::getConf('maestro.debug.maxLen');
         // default: 150
     }
     error_reporting(self::getConf('maestro.debug.severity'));
     // Maestro 1.0 compatibility
     // self::addAutoloadClass('mlogin', self::$classPath . '/Security/MLoginMaestro1.php');
     // Session
     self::$session = new MSession();
     self::$session->init($_REQUEST['sid'] === '0' ? 0 : mrequest('sid'));
     self::$baseURL = self::$request->getBaseURL(false);
     Manager::logMessage('[RESET_LOG_MESSAGES]');
     /*
             if (self::$java = ($_SERVER["SERVER_SOFTWARE"] == "JavaBridge")) {
        require_once (self::$home . "/java/Java.inc");
        self::$javaContext = java_context();
        self::$javaServletContext = java_context()->getServletContext();
             }
     * 
     */
     self::getLogin();
     self::$msg = new MMessages(self::getSession()->lang ?: self::getOptions('language'));
     self::$msg->loadMessages();
     self::$mode = self::getOptions("mode");
     date_default_timezone_set(self::getOptions("timezone"));
     setlocale(LC_ALL, self::getOptions("locale"));
     //self::$mad = self::getConf('maestro.mad.module');
     self::$app = self::getConf('maestro.app');
     register_shutdown_function("shutdown");
 }
Esempio n. 14
0
 /**
  * Simple trace info
  *
  * @param array $stack
  * @return string
  */
 public static function showTraceSimple($stack)
 {
     $maxDepth = Debugger::$maxDepth;
     Debugger::$maxDepth = 1;
     $counter = 0;
     ob_start();
     foreach ($stack as $row) {
         try {
             $r = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']);
             $params = $r->getParameters();
         } catch (\Exception $e) {
             $params = array();
         }
         $args = array();
         if (array_key_exists('args', $row)) {
             $argList = new \ArrayIterator($row['args']);
             while ($argList->valid()) {
                 $key = $argList->key();
                 $args[] = !isset($params[$key]) ?: '$' . $params[$key]->name;
                 $argList->next();
             }
         }
         echo ++$counter . '. <b>' . (isset($row['class']) ? htmlspecialchars($row['class'] . $row['type']) : '') . htmlspecialchars($row['function']) . '(' . implode(', ', $args) . ');</b> ' . '<br>' . (isset($row['file']) && is_file($row['file']) ? Helpers::editorLink($row['file'], $row['line']) : '<i>inner-code</i>' . isset($row['line']) ?: $row['line']) . '<br>';
         if ($counter == self::$traceMode) {
             break;
         }
     }
     Debugger::$maxDepth = $maxDepth;
     return ob_get_clean();
 }