diff --git a/framework/yii/debug/LogTarget.php b/framework/yii/debug/LogTarget.php index 9c00300..98c2624 100644 --- a/framework/yii/debug/LogTarget.php +++ b/framework/yii/debug/LogTarget.php @@ -57,6 +57,7 @@ class LogTarget extends Target 'ip' => $request->getUserIP(), 'time' => time(), ); + $this->gc($manifest); $dataFile = "$path/{$this->tag}.json"; $data = array(); @@ -82,4 +83,19 @@ class LogTarget extends Target $this->export($this->messages); } } + + protected function gc(&$manifest) + { + if (rand(0, 100) < 5 && count($manifest) > $this->module->historySize) { + $n = count($manifest) - $this->module->historySize; + foreach (array_keys($manifest) as $tag) { + $file = $this->module->dataPath . "/$tag.json"; + @unlink($file); + unset($manifest[$tag]); + if (--$n <= 0) { + break; + } + } + } + } } diff --git a/framework/yii/debug/panels/LogPanel.php b/framework/yii/debug/panels/LogPanel.php index 9d1cc0c..04e6903 100644 --- a/framework/yii/debug/panels/LogPanel.php +++ b/framework/yii/debug/panels/LogPanel.php @@ -29,11 +29,11 @@ class LogPanel extends Panel $output = array(); $errorCount = count(Target::filterMessages($this->data['messages'], Logger::LEVEL_ERROR)); if ($errorCount) { - $output[] = '$errorCount ' . ($errorCount > 1 ? 'errors' : 'error'); + $output[] = '' . $errorCount . ' ' . ($errorCount > 1 ? 'errors' : 'error'); } $warningCount = count(Target::filterMessages($this->data['messages'], Logger::LEVEL_WARNING)); if ($warningCount) { - $output[] = '$warningCount ' . ($warningCount > 1 ? 'warnings' : 'warning'); + $output[] = '' . $warningCount . ' ' . ($warningCount > 1 ? 'warnings' : 'warning'); } if (!empty($output)) { $log = implode(', ', $output); diff --git a/framework/yii/debug/panels/RequestPanel.php b/framework/yii/debug/panels/RequestPanel.php index b49bf63..bc85c4a 100644 --- a/framework/yii/debug/panels/RequestPanel.php +++ b/framework/yii/debug/panels/RequestPanel.php @@ -107,7 +107,7 @@ EOD; 'flashes' => $session ? $session->getAllFlashes() : array(), 'requestHeaders' => $requestHeaders, 'responseHeaders' => $responseHeaders, - 'route' => Yii::$app->requestedAction->getUniqueId(), + 'route' => Yii::$app->requestedAction ? Yii::$app->requestedAction->getUniqueId() : Yii::$app->requestedRoute, 'action' => $action, 'actionParams' => Yii::$app->requestedParams, 'SERVER' => empty($_SERVER) ? array() : $_SERVER,