summaryrefslogtreecommitdiff
path: root/framework/Util
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2010-02-14 01:22:57 +0000
committergodzilla80@gmx.net <>2010-02-14 01:22:57 +0000
commit94e94e0a8566f23d16658a04c55b0bbfdd6689aa (patch)
tree72ffad82c279080dd9320d45dda26d64ffb4626f /framework/Util
parent966fd66f217911d079c4bd6a87b09f4a0c5c4736 (diff)
Merge Branches & Trunk
/trunk:r2680,2692,2707-2736 /branches/3.1:r2682-2686,2694-2702,2705,2738-2762
Diffstat (limited to 'framework/Util')
-rw-r--r--framework/Util/TLogRouter.php87
1 files changed, 78 insertions, 9 deletions
diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php
index a8f42b56..c944e17d 100644
--- a/framework/Util/TLogRouter.php
+++ b/framework/Util/TLogRouter.php
@@ -635,6 +635,11 @@ class TEmailLogRoute extends TLogRoute
*/
class TBrowserLogRoute extends TLogRoute
{
+ /**
+ * @var string css class for indentifying the table structure in the dom tree
+ */
+ private $_cssClass=null;
+
public function processLogs($logs)
{
if(empty($logs) || $this->getApplication()->getMode()==='Performance') return;
@@ -659,10 +664,43 @@ class TBrowserLogRoute extends TLogRoute
}
$response->write($this->renderFooter());
}
+
+ /**
+ * @param string the css class of the control
+ */
+ public function setCssClass($value)
+ {
+ $this->_cssClass = TPropertyValue::ensureString($value);
+ }
+
+ /**
+ * @return string the css class of the control
+ */
+ public function getCssClass()
+ {
+ return TPropertyValue::ensureString($this->_cssClass);
+ }
protected function renderHeader()
{
- $string = <<<EOD
+ $string = '';
+ if($className=$this->getCssClass())
+ {
+ $string = <<<EOD
+<table class="$className">
+ <tr class="header">
+ <th colspan="5">
+ Application Log
+ </th>
+ </tr><tr class="description">
+ <th>&nbsp;</th>
+ <th>Category</th><th>Message</th><th>Time Spent (s)</th><th>Cumulated Time Spent (s)</th>
+ </tr>
+EOD;
+ }
+ else
+ {
+ $string = <<<EOD
<table cellspacing="0" cellpadding="2" border="0" width="100%" style="table-layout:auto">
<tr>
<th style="background-color: black; color:white;" colspan="5">
@@ -673,18 +711,36 @@ class TBrowserLogRoute extends TLogRoute
<th style="width: auto">Category</th><th style="width: auto">Message</th><th style="width: 120px">Time Spent (s)</th><th style="width: 150px">Cumulated Time Spent (s)</th>
</tr>
EOD;
+ }
return $string;
}
protected function renderMessage($log, $info)
{
- $bgcolor = $info['even'] ? "#fff" : "#eee";
+ $string = '';
$total = sprintf('%0.6f', $info['total']);
$delta = sprintf('%0.6f', $info['delta']);
- $color = $this->getColorLevel($log[1]);
$msg = preg_replace('/\(line[^\)]+\)$/','',$log[0]); //remove line number info
$msg = THttpUtility::htmlEncode($msg);
- $string = <<<EOD
+ if($this->getCssClass())
+ {
+ $colorCssClass = $log[1];
+ $messageCssClass = $info['even'] ? 'even' : 'odd';
+ $string = <<<EOD
+ <tr class="message level$colorCssClass $messageCssClass">
+ <td class="code">&nbsp;</td>
+ <td class="category">{$log[2]}</td>
+ <td class="message">{$msg}</td>
+ <td class="time">{$delta}</td>
+ <td class="cumulatedtime">{$total}</td>
+ </tr>
+EOD;
+ }
+ else
+ {
+ $bgcolor = $info['even'] ? "#fff" : "#eee";
+ $color = $this->getColorLevel($log[1]);
+ $string = <<<EOD
<tr style="background-color: {$bgcolor}; color:#000">
<td style="border:1px solid silver;background-color: $color;">&nbsp;</td>
<td>{$log[2]}</td>
@@ -693,6 +749,7 @@ EOD;
<td style="text-align:center">{$total}</td>
</tr>
EOD;
+ }
return $string;
}
@@ -713,13 +770,25 @@ EOD;
protected function renderFooter()
{
- $string = "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">";
- foreach(self::$_levelValues as $name => $level)
+ $string = '';
+ if($this->getCssClass())
{
- $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level);
- $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>";
+ $string .= '<tr class="footer"><td colspan="5">';
+ foreach(self::$_levelValues as $name => $level)
+ {
+ $string .= '<span class="level'.$level.'">'.strtoupper($name)."</span>";
+ }
+ }
+ else
+ {
+ $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">";
+ foreach(self::$_levelValues as $name => $level)
+ {
+ $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level);
+ $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>";
+ }
}
- $string .= "</td></tr></table>";
+ $string .= '</td></tr></table>';
return $string;
}
}