Browse Source

minor issue fixes.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
14507bf6d8
  1. 16
      framework/yii/debug/LogTarget.php
  2. 4
      framework/yii/debug/panels/LogPanel.php
  3. 2
      framework/yii/debug/panels/RequestPanel.php

16
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;
}
}
}
}
}

4
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[] = '<span class="label label-important">$errorCount</span> ' . ($errorCount > 1 ? 'errors' : 'error');
$output[] = '<span class="label label-important">' . $errorCount . '</span> ' . ($errorCount > 1 ? 'errors' : 'error');
}
$warningCount = count(Target::filterMessages($this->data['messages'], Logger::LEVEL_WARNING));
if ($warningCount) {
$output[] = '<span class="label label-warning">$warningCount</span> ' . ($warningCount > 1 ? 'warnings' : 'warning');
$output[] = '<span class="label label-warning">' . $warningCount . '</span> ' . ($warningCount > 1 ? 'warnings' : 'warning');
}
if (!empty($output)) {
$log = implode(', ', $output);

2
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,

Loading…
Cancel
Save