Commit 14507bf6 by Qiang Xue

minor issue fixes.

parent 7a4572fd
......@@ -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;
}
}
}
}
}
......@@ -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);
......
......@@ -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,
......
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