Load debugger as early as possible

This commit is contained in:
Matias Griese 2014-10-14 09:51:55 +03:00
parent 45e79f88a3
commit c89f683b8c
3 changed files with 7 additions and 9 deletions

View File

@ -11,7 +11,6 @@ if (!is_file($autoload)) {
}
use Grav\Common\Grav;
use Grav\Common\Debugger;
// Register the auto-loader.
$loader = require_once $autoload;
@ -27,7 +26,6 @@ $grav = Grav::instance(
);
try {
$grav['debugger'];
$grav->process();
} catch (\Exception $e) {

View File

@ -16,13 +16,15 @@ class Debugger
protected $debugbar;
protected $renderer;
public function __construct() {
$this->grav = Grav::instance();
public function __construct()
{
$this->debugbar = new StandardDebugBar();
}
public function init()
{
$this->grav = Grav::instance();
$config = $this->grav['config'];
if ($config->get('system.debugger.enabled')) {
$this->debugbar->addCollector(new \DebugBar\DataCollector\ConfigCollector((array)$config->get('system')));
@ -76,7 +78,7 @@ class Debugger
public function startTimer($name, $desription = null)
{
$config = $this->grav['config'];
if ($config->get('system.debugger.enabled') || $name == 'config' || $name == 'debugger') {
if ($name == 'config' || $name == 'debugger' || $config->get('system.debugger.enabled')) {
$this->debugbar['time']->startMeasure($name, $desription);
}
return $this;
@ -85,7 +87,7 @@ class Debugger
public function stopTimer($name)
{
$config = $this->grav['config'];
if ($config->get('system.debugger.enabled') || $name == 'config' || $name == 'debugger') {
if ($name == 'config' || $name == 'debugger' || $config->get('system.debugger.enabled')) {
$this->debugbar['time']->stopMeasure($name);
}
return $this;

View File

@ -53,9 +53,7 @@ class Grav extends Container
$container['grav'] = $container;
$container['debugger'] = function ($c) {
return new Debugger($c);
};
$container['debugger'] = new Debugger();
$container['uri'] = function ($c) {
return new Uri($c);