diff --git a/framework/yii/debug/LogTarget.php b/framework/yii/debug/LogTarget.php index b2081be..71478ce 100644 --- a/framework/yii/debug/LogTarget.php +++ b/framework/yii/debug/LogTarget.php @@ -20,12 +20,14 @@ class LogTarget extends Target * @var Module */ public $module; - public $maxLogFiles = 20; + public $tag; + public $historySize = 20; public function __construct($module, $config = array()) { parent::__construct($config); $this->module = $module; + $this->tag = date('Ymd-His', microtime(true)); } /** @@ -38,8 +40,7 @@ class LogTarget extends Target if (!is_dir($path)) { mkdir($path); } - $tag = Yii::$app->getLog()->getTag(); - $file = "$path/$tag.log"; + $file = "$path/{$this->tag}.log"; $data = array(); foreach ($this->module->panels as $panel) { $data[$panel->id] = $panel->save(); @@ -78,8 +79,8 @@ class LogTarget extends Target } } sort($files); - if (count($files) > $this->maxLogFiles) { - $n = count($files) - $this->maxLogFiles; + if (count($files) > $this->historySize) { + $n = count($files) - $this->historySize; foreach ($files as $i => $file) { if ($i < $n) { unlink($file); diff --git a/framework/yii/debug/Module.php b/framework/yii/debug/Module.php index 2b20cc1..c084fad 100644 --- a/framework/yii/debug/Module.php +++ b/framework/yii/debug/Module.php @@ -63,8 +63,9 @@ class Module extends \yii\base\Module { /** @var View $view */ $id = 'yii-debug-toolbar'; + $tag = Yii::$app->getLog()->targets['debug']->tag; $url = Yii::$app->getUrlManager()->createUrl('debug/default/toolbar', array( - 'tag' => Yii::$app->getLog()->getTag(), + 'tag' => $tag, )); $view = $event->sender; $view->registerJs("yii.debug.load('$id', '$url');"); diff --git a/framework/yii/debug/controllers/DefaultController.php b/framework/yii/debug/controllers/DefaultController.php index a80201b..b63bc4b 100644 --- a/framework/yii/debug/controllers/DefaultController.php +++ b/framework/yii/debug/controllers/DefaultController.php @@ -40,6 +40,7 @@ class DefaultController extends Controller { $this->loadData($tag); return $this->renderPartial('toolbar', array( + 'tag' => $tag, 'panels' => $this->module->panels, )); } diff --git a/framework/yii/debug/panels/ConfigPanel.php b/framework/yii/debug/panels/ConfigPanel.php index e513caf..9e19c90 100644 --- a/framework/yii/debug/panels/ConfigPanel.php +++ b/framework/yii/debug/panels/ConfigPanel.php @@ -24,12 +24,10 @@ class ConfigPanel extends Panel public function getSummary() { - $link = Html::a('more details', array('index', 'tag' => $this->data['tag'])); return << PHP: {$this->data['phpVersion']}, - Yii: {$this->data['phpVersion']}, - $link + Yii: {$this->data['phpVersion']} EOD; } @@ -42,7 +40,6 @@ EOD; public function save() { return array( - 'tag' => Yii::$app->getLog()->getTag(), 'phpVersion' => PHP_VERSION, 'yiiVersion' => Yii::getVersion(), ); diff --git a/framework/yii/debug/views/default/toolbar.php b/framework/yii/debug/views/default/toolbar.php index a7958fe..10f66a5 100644 --- a/framework/yii/debug/views/default/toolbar.php +++ b/framework/yii/debug/views/default/toolbar.php @@ -2,7 +2,9 @@ /** * @var \yii\base\View $this * @var \yii\debug\Panel[] $panels + * @var string $tag */ +use yii\helpers\Html; ?>