public function __construct($mode = self::PRODUCTION) { // Start the timer and enable debugger in production mode as we do not have system configuration yet. // Debugger catches all errors and logs them, for example if the script doesn't have write permissions. TracyDebugger::timer(); TracyDebugger::enable($mode, is_dir(LOG_DIR) ? LOG_DIR : null); }
/** * {@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(); } } }
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(); } }
public function onAfterDebug(Container $c) { $p = $c->parameters; if (isset($p['forceDebug'])) { $mode = $p['forceDebug'] === FALSE ? Debugger::PRODUCTION : Debugger::DEVELOPMENT; Debugger::enable($mode, LOG_DIR, '*****@*****.**'); } }
/** * @param $enableMode * @return $this */ private function enableDebuggerWith($enableMode) { if ($this->isLoggerEnabled() == true) { Debugger::enable($enableMode, $this->getLogPath()); } else { Debugger::enable($enableMode); } return $this; }
/** * Enables displaying or logging errors and exceptions. * @param mixed production, development mode, autodetection or IP address(es) whitelist. * @param string error log directory; enables logging in production mode, FALSE means that logging is disabled * @param string administrator email; enables email sending in production mode * @return void */ public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL) { parent::enable($mode, $logDirectory, $email); self::$blueScreen = self::getBlueScreen(); self::$bar = self::getBar(); self::$logger = self::getLogger(); self::$fireLogger = self::getFireLogger(); self::$consoleColors =& Tracy\Dumper::$terminalColors; }
/** * Enables displaying or logging errors and exceptions. * @param mixed production, development mode, autodetection or IP address(es) whitelist. * @param string error log directory; enables logging in production mode, FALSE means that logging is disabled * @param string administrator email; enables email sending in production mode * @return void */ public static function enable($mode = NULL, $logDirectory = NULL, $email = NULL) { trigger_error(__CLASS__ . ' is deprecated, use Tracy\\Debugger.', E_USER_DEPRECATED); parent::enable($mode, $logDirectory, $email); self::$blueScreen = self::getBlueScreen(); self::$bar = self::getBar(); self::$logger = self::getLogger(); self::$fireLogger = self::getFireLogger(); self::$consoleColors =& Tracy\Dumper::$terminalColors; }
/** * @param $enableMode * @param array $config */ private function enableDebuggerWith($enableMode, $config = array()) { $this->enableLogging = $config['enable_logging']; if ($config['enable_logging'] == true) { $logPath = str_replace('.', '/', $config['log_path']) . '/'; Debugger::enable($enableMode, $logPath); } else { Debugger::enable($enableMode); } }
public function __construct(array $allowedIpAddresses = array(), array $allowedMethods = array(), array $allowedUserAgents = array(), $logDirectory = NULL) { $httpRequestFactory = new Http\RequestFactory(); $this->allowedIpAddresses = $allowedIpAddresses; $this->allowedMethods = $allowedMethods; $this->allowedUserAgents = $allowedUserAgents; $this->httpRequest = $httpRequestFactory->createHttpRequest(); if (!Debugger::isEnabled() && $logDirectory) { Debugger::enable(Debugger::DETECT, $logDirectory); Debugger::$logSeverity = E_NOTICE | E_WARNING; } }
/** * 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']; }
/** * instance. * * @method instance * * @param array$config * * @return static */ public static function instance($config = []) { static $instance; if (is_null($instance) === false) { return $instance; } $config = array_merge(['enabled' => true, 'showBar' => true, 'editor' => 'subl://open?url=file://%file&line=%line', 'maxDepth' => 4, 'maxLength' => 1000, 'scream' => true, 'showLocation' => true, 'strictMode' => true, 'panels' => ['routing' => false, 'database' => true, 'view' => false, 'event' => false, 'session' => true, 'request' => true, 'auth' => false, 'terminal' => false]], $config); $config['enabled'] = Arr::get($config, 'enabled', false); $config['showBar'] = Arr::get($config, 'showBar', false); $mode = isset($config['enabled']) === false ? Debugger::DETECT : $config['enabled'] === true ? Debugger::DEVELOPMENT : Debugger::PRODUCTION; Debugger::enable($mode); $debugbar = new Debugbar($config); $debugbar->setup(); return $instance = $debugbar; }
public function renderDefault() { \Tracy\Debugger::enable(\Tracy\Debugger::PRODUCTION); $session = $this->getSession('cms'); $this->context->getService('menuModel')->setSiteId($session->siteId); $this->context->getService('configurationModel')->setLanguageId($session->languageId); $post = $this->request->post; try { $this->template->response = $this->{$post['action']}(json_decode($post['data'])); } catch (Exception $ex) { if ($ex instanceof CmsException) { $this->template->response = array('errorCode' => 2, 'error' => $ex->getMessage()); } else { $this->template->response = array('errorCode' => 1, 'error' => $ex->getMessage() . 'on line ' . $ex->getLine() . ' at ' . $ex->getFile() . "\n\n" . $ex->getTraceAsString()); \Tracy\Debugger::log($ex); } } }
/** * @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']; }; } }
<?php use Nette\Caching\Storages\FileStorage; use Nette\Loaders\RobotLoader; use Tracy\Debugger; use VersionPress\DI\DIContainer; use VersionPress\DI\VersionPressServices; define('VERSIONPRESS_PLUGIN_DIR', __DIR__); define('VERSIONPRESS_MIRRORING_DIR', WP_CONTENT_DIR . '/vpdb'); define('VERSIONPRESS_TEMP_DIR', VERSIONPRESS_PLUGIN_DIR . '/temp'); define('VERSIONPRESS_ACTIVATION_FILE', VERSIONPRESS_MIRRORING_DIR . '/.active'); require_once VERSIONPRESS_PLUGIN_DIR . '/versionpress-functions.php'; if (defined('DOING_AJAX')) { header("Content-Type: application/json"); } Debugger::enable(Debugger::DEVELOPMENT, VERSIONPRESS_PLUGIN_DIR . '/log'); $robotLoader = new RobotLoader(); $robotLoader->addDirectory(VERSIONPRESS_PLUGIN_DIR . '/src'); $robotLoader->setCacheStorage(new FileStorage(VERSIONPRESS_PLUGIN_DIR . '/temp')); $robotLoader->register(); global $versionPressContainer; $versionPressContainer = DIContainer::getConfiguredInstance();
<?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)
/** * @param string error log directory * @param string administrator email * @return void */ public function enableDebugger($logDirectory = NULL, $email = NULL) { Tracy\Debugger::$strictMode = TRUE; Tracy\Debugger::enable(!$this->parameters['debugMode'], $logDirectory, $email); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; define('LOG_DIR', __DIR__ . '/../log'); define('TEMP_DIR', __DIR__ . '/../temp/cache'); @mkdir(LOG_DIR); @mkdir(TEMP_DIR); \Tracy\Debugger::enable(\Tracy\Debugger::DEVELOPMENT, LOG_DIR); \Tracy\Debugger::$strictMode = true; ?> <!DOCTYPE html> <html lang="en" class=" is-copy-enabled is-u2f-enabled"> <head> <title>Mesour DataGrid sandbox</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css"> <link rel="stylesheet" href="css/font-awesome.min.css"> <link rel="stylesheet" href="css/mesour.grid.min.css"> </head> <body> <?php $time_start = microtime(true);
define('SRC_DIR', BASE_DIR . 'src/'); /* * Handle Cloudflare usage */ $_SERVER['REMOTE_ADDR'] = isset($_SERVER['HTTP_CF_CONNECTING_IP']) ? $_SERVER['HTTP_CF_CONNECTING_IP'] : $_SERVER['REMOTE_ADDR']; require_once SRC_DIR . 'core/autoloader.php'; Twig_Autoloader::register(); /* * Set Debugger::DETECT to Debugger::DEVELOPMENT to force errors to be displayed. * This should NEVER be done on a live environment. In most cases Debugger is smart * enough to figure out if it is a local or development environment. */ if (Config::config('debugging') === true) { Debugger::enable(Debugger::DEVELOPMENT, SRC_DIR . '/logs'); } else { Debugger::enable(Debugger::DETECT, SRC_DIR . '/logs'); } Debugger::$strictMode = true; /* * MySQL PDO Connection Engine */ ORM::configure(array('connection_string' => 'mysql:host=' . Config::config('mysql')->host . ';port=' . Config::config('mysql')->port . ';dbname=' . Config::config('mysql')->database, 'username' => Config::config('mysql')->username, 'password' => Config::config('mysql')->password, 'driver_options' => array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC), 'logging' => true, 'logger' => function ($query, $time) { DatabaseManager::logQuery($query, $time); }, 'caching' => true, 'caching_auto_clear' => true)); /* * Initalize Global core */ $core = new stdClass(); $klein = new \Klein\Klein(); $core->auth = new Authentication(); $core->user = new User();
* such as the configuration.php file are stored in it. In this instance, we need to check the $_SERVER var for our * correct document root path as the above checks the symlinked location */ if (!defined('_CDEFINES')) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/defines.php')) { require_once $_SERVER['DOCUMENT_ROOT'] . '/defines.php'; } } /* * If at this point _CDEFINES hasn't been defined, we will assume that a custom defines file has not been included and we * will use the system default path. */ if (!defined('_CDEFINES')) { define('_CDEFINES', false); require_once __DIR__ . '/src/defines.php'; } require_once __DIR__ . '/src/boot.php'; if (COBALT_CLI) { try { $app = new \Cobalt\CLI\Application(); $app->execute(); } catch (\Exception $e) { fwrite(STDOUT, "\nERROR: " . $e->getMessage() . "\n"); fwrite(STDOUT, "\n" . $e->getTraceAsString() . "\n"); exit; } } else { \Tracy\Debugger::enable(); $app = new \Cobalt\Application(); $app->execute(); }
<?php namespace CC15; use Symfony\Component\HttpFoundation\Request; use Tracy\Debugger; require_once __DIR__ . "/../vendor/autoload.php"; $env = "dev"; Debugger::enable($env !== "dev", __DIR__ . "/../log"); $request = Request::createFromGlobals(); $kernel = new CC15Kernel($env, $env === "dev"); $response = $kernel->handle($request); if ($env === "dev") { // ->send() calls fastcgi_finish_request(), so no other content would get rendered (e.g. Tracy debug bar) $response->sendHeaders(); $response->sendContent(); } else { $response->send(); } $kernel->terminate($request, $response);
<?php include __DIR__ . '/libs/Loader.php'; use libs\SessionManager; use libs\MessageBuffer; use Tracy\Debugger; Debugger::enable(Debugger::DEVELOPMENT); SessionManager::run($demo = false); \model\services\DB_Service::$message_buffer = MessageBuffer::getInstance("PDO_error_log"); $dispatcher = Loader::createDispatcher(); $dispatcher->dispatch();
define('SRC_DIR', BASE_DIR . 'src/'); /* * Handle Cloudflare usage */ $_SERVER['REMOTE_ADDR'] = isset($_SERVER['HTTP_CF_CONNECTING_IP']) ? $_SERVER['HTTP_CF_CONNECTING_IP'] : $_SERVER['REMOTE_ADDR']; require_once SRC_DIR . 'core/autoloader.php'; Twig_Autoloader::register(); /* * Set Debugger::DETECT to Debugger::DEVELOPMENT to force errors to be displayed. * This should NEVER be done on a live environment. In most cases Debugger is smart * enough to figure out if it is a local or development environment. */ if (Config::config('debugging') === true) { Debugger::enable(Debugger::DEVELOPMENT, BASE_DIR . '/logs'); } else { Debugger::enable(Debugger::DETECT, BASE_DIR . '/logs'); } Debugger::$strictMode = true; /* * MySQL PDO Connection Engine */ ORM::configure(array('connection_string' => 'mysql:host=' . Config::config('mysql')->host . ';port=' . Config::config('mysql')->port . ';dbname=' . Config::config('mysql')->database, 'username' => Config::config('mysql')->username, 'password' => Config::config('mysql')->password, 'driver_options' => array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC), 'logging' => true, 'logger' => function ($query, $time) { DatabaseManager::logQuery($query, $time); }, 'caching' => true, 'caching_auto_clear' => true)); /* * Initalize Global core */ $core = new stdClass(); $klein = new \Klein\Klein(); $core->auth = new Authentication(); $core->user = new User();
/** * @param string error log directory * @param string administrator email * @return void */ public function enableDebugger($logDirectory = NULL, $email = NULL) { Tracy\Debugger::$strictMode = TRUE; Tracy\Debugger::enable(!$this->parameters['debugMode'], $logDirectory, $email); Nette\Bridges\Framework\TracyBridge::initialize(); }
public function startup() { parent::startup(); Debugger::enable(Debugger::PRODUCTION); }
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css"> <style> html { background: url(assets/arrow.png) no-repeat bottom right; height: 100%; } </style> <h1>Tracy Debug Bar demo</h1> <p>You can dump variables to bar in rightmost bottom egde.</p> <?php require __DIR__ . '/../src/tracy.php'; use Tracy\Debugger; Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/log'); $arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array()); Debugger::barDump(get_defined_vars()); Debugger::barDump($arr, 'The Array'); Debugger::barDump('<a href="#">test</a>', 'String');
<?php if (!($loader = (include __DIR__ . '/../vendor/autoload.php'))) { echo 'Install Nette Tester using `composer update --dev`'; exit(1); } $loader->addPsr4('LibretteTests\\Doctrine\\Queries\\', __DIR__ . '/src'); \Tracy\Debugger::enable(\Tracy\Debugger::DEVELOPMENT, __DIR__ . '/tmp/'); // configure environment Tester\Environment::setup(); class_alias('Tester\\Assert', 'Assert'); date_default_timezone_set('Europe/Prague'); // create temporary directory define('TEMP_DIR', __DIR__ . '/tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); Tester\Helpers::purge(TEMP_DIR); $_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'))); $_SERVER['REQUEST_TIME'] = 1234567890; $_ENV = $_GET = $_POST = array(); function run(Tester\TestCase $testCase) { $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL); }
/** * RadekDostal\NetteComponents\DateTimePicker\DateTimePicker example * * @package RadekDostal\NetteComponents\DateTimePicker * @example https://componette.com/radekdostal/nette-datetimepicker/ * @author Ing. Radek Dostál, Ph.D. <*****@*****.**> * @copyright Copyright (c) 2010 - 2016 Radek Dostál * @license GNU Lesser General Public License * @link http://www.radekdostal.cz */ use Nette\Forms\Form; use Tracy\Debugger; require '../vendor/autoload.php'; Debugger::$strictMode = TRUE; Debugger::enable(); RadekDostal\NetteComponents\DateTimePicker\DateTimePicker::register(); $form = new Form(); $form->addDateTimePicker('datetime', 'Date and time:', 16)->setRequired()->setAttribute('size', 16); $form->addSubmit('submit', 'Send'); if ($form->isSuccess() === TRUE) { echo '<h2>Form was submitted and successfully validated</h2>'; Debugger::dump($form->getValues()); exit; } /*else { $form->setDefaults(array( 'datetime' => new \DateTime() )); }*/
<?php use Composer\Autoload\ClassLoader; use VersionPress\Storages\Mirror; use VersionPress\Storages\StorageFactory; use VersionPress\Tests\Utils\HookMock; $opts = ['from:', 'to:']; $args = getopt('', $opts); if (count($args) < count($opts)) { die("Please specify all arguments\n"); } require_once __DIR__ . '/../../vendor/autoload.php'; \Tracy\Debugger::enable(\Tracy\Debugger::DEVELOPMENT, __DIR__); $classloader = new ClassLoader(); $classloader->addPsr4('VersionPress\\', __DIR__ . '/../../src'); $classloader->register(); HookMock::setUp(HookMock::TRUE_HOOKS); // @codingStandardsIgnoreLine class FooChangeInfo extends \VersionPress\ChangeInfos\TrackedChangeInfo { private $files; public function __construct($files) { $this->files = $files; } public function getChangeDescription() { return join("\n", $this->files); } public function getScope() {
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css"> <h1>Tracy Warning and StrictMode demo</h1> <?php require __DIR__ . '/../src/tracy.php'; use Tracy\Debugger; Debugger::enable(Debugger::DETECT, __DIR__ . '/log'); Debugger::$strictMode = TRUE; $f = fopen('nonexistent', 'r');
* 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 :) */