Commit b0b8056f by Qiang Xue

Fixes #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default

parent 740f5325
......@@ -54,6 +54,12 @@ class Module extends \yii\base\Module implements BootstrapInterface
* the oldest ones will be removed.
*/
public $historySize = 50;
/**
* @var boolean whether to enable message logging for the requests about debug module actions.
* You normally do not want to keep these logs because they may distract you from the logs about your applications.
* You may want to enable the debug logs if you want to investigate how the debug module itself works.
*/
public $enableDebugLogs = false;
/**
* Returns Yii logo ready to use in `<img src="`
......@@ -118,13 +124,23 @@ class Module extends \yii\base\Module implements BootstrapInterface
*/
public function beforeAction($action)
{
if (!parent::beforeAction($action)) {
return false;
}
if (!$this->enableDebugLogs) {
foreach (Yii::$app->getLog()->targets as $target) {
$target->enabled = false;
}
}
// do not display debug toolbar when in debug view mode
Yii::$app->getView()->off(View::EVENT_END_BODY, [$this, 'renderToolbar']);
unset(Yii::$app->getLog()->targets['debug']);
$this->logTarget = null;
if ($this->checkAccess()) {
return parent::beforeAction($action);
return true;
} elseif ($action->id === 'toolbar') {
// Accessing toolbar remotely is normal. Do not throw exception.
return false;
} else {
throw new ForbiddenHttpException('You are not allowed to access this page.');
......
......@@ -5,6 +5,7 @@ Yii Framework 2 Change Log
--------------------------
- Bug #3091: Fixed inconsistent treatment of `Widget::run()` when a widget is used as a container and as a self-contained object (qiangxue)
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
- no changes in this release.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment