From a2c87c83d3bb8f16049674ddba260f58b698bfb7 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 9 Jan 2006 05:41:33 +0000 Subject: added TBrowserLogRoute --- framework/Log/TLogRouter.php | 60 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'framework/Log/TLogRouter.php') diff --git a/framework/Log/TLogRouter.php b/framework/Log/TLogRouter.php index b3688961..89214d80 100644 --- a/framework/Log/TLogRouter.php +++ b/framework/Log/TLogRouter.php @@ -157,7 +157,6 @@ abstract class TLogRoute extends TComponent TLogger::INFO=>'Info', TLogger::NOTICE=>'Notice', TLogger::WARNING=>'Warning', - TLogger::ERROR=>'Error', TLogger::ALERT=>'Alert', TLogger::FATAL=>'Fatal' ); @@ -169,7 +168,6 @@ abstract class TLogRoute extends TComponent 'info'=>TLogger::INFO, 'notice'=>TLogger::NOTICE, 'warning'=>TLogger::WARNING, - 'error'=>TLogger::ERROR, 'alert'=>TLogger::ALERT, 'fatal'=>TLogger::FATAL ); @@ -568,4 +566,62 @@ class TEmailLogRoute extends TLogRoute } } +class TBrowserLogRoute extends TLogRoute +{ + public function processLogs($logs) + { + $first = $logs[0][3]; + $prev = $first; + $total = 0; + $delta = 0; + $even = true; + echo $this->renderHeader(); + foreach($logs as $log) + { + $total += $log[3] - $first; + $timing['total'] = $total; + $timing['delta'] = $log[3]-$prev; + $timing['even'] = $even; + $prev=$log[3]; + $even = !$even; + echo $this->renderMessage($log,$timing); + } + echo $this->renderFooter(); + } + + protected function renderHeader() + { + $category = is_array($this->getCategories()) ? + implode(', ',$this->getCategories()) : ''; + $string = << + + +

Trace Information: $category

+ + + CategoryMessageFrom First(s)From Last(s) + +EOD; + return $string; + } + + protected function renderMessage($log, $info) + { + $color = $info['even'] ? "#fff" : "#eee"; + $total = sprintf('%0.6f', $info['total']); + $delta = sprintf('%0.6f', $info['delta']); + $string = << + {$log[2]}{$log[0]}{$total}{$delta} + +EOD; + return $string; + } + + protected function renderFooter() + { + return ""; + } +} ?> \ No newline at end of file -- cgit v1.2.3