mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-24 16:07:19 +01:00
Yii debugger WIP
This commit is contained in:
@@ -27,6 +27,10 @@ class Module extends \yii\base\Module
|
||||
public $allowedIPs = array('127.0.0.1', '::1');
|
||||
|
||||
public $controllerNamespace = 'yii\debug\controllers';
|
||||
/**
|
||||
* @var LogTarget
|
||||
*/
|
||||
public $logTarget;
|
||||
/**
|
||||
* @var array|Panel[]
|
||||
*/
|
||||
@@ -36,19 +40,20 @@ class Module extends \yii\base\Module
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->logTarget = Yii::$app->getLog()->targets['debug'] = new LogTarget($this);
|
||||
Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar'));
|
||||
|
||||
foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) {
|
||||
$config['id'] = $id;
|
||||
$config['module'] = $this;
|
||||
$this->panels[$id] = Yii::createObject($config);
|
||||
}
|
||||
|
||||
Yii::$app->getLog()->targets['debug'] = new LogTarget($this);
|
||||
Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar'));
|
||||
}
|
||||
|
||||
public function beforeAction($action)
|
||||
{
|
||||
Yii::$app->getView()->off(View::EVENT_END_BODY, array($this, 'renderToolbar'));
|
||||
unset(Yii::$app->getLog()->targets['debug']);
|
||||
$this->logTarget = null;
|
||||
|
||||
$ip = Yii::$app->getRequest()->getUserIP();
|
||||
foreach ($this->allowedIPs as $filter) {
|
||||
@@ -63,7 +68,7 @@ class Module extends \yii\base\Module
|
||||
{
|
||||
/** @var View $view */
|
||||
$id = 'yii-debug-toolbar';
|
||||
$tag = Yii::$app->getLog()->targets['debug']->tag;
|
||||
$tag = $this->logTarget->tag;
|
||||
$url = Yii::$app->getUrlManager()->createUrl('debug/default/toolbar', array(
|
||||
'tag' => $tag,
|
||||
));
|
||||
@@ -88,6 +93,12 @@ class Module extends \yii\base\Module
|
||||
'log' => array(
|
||||
'class' => 'yii\debug\panels\LogPanel',
|
||||
),
|
||||
'profiling' => array(
|
||||
'class' => 'yii\debug\panels\ProfilingPanel',
|
||||
),
|
||||
'db' => array(
|
||||
'class' => 'yii\debug\panels\DbPanel',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user