diff options
author | tof <> | 2008-02-22 17:22:17 +0000 |
---|---|---|
committer | tof <> | 2008-02-22 17:22:17 +0000 |
commit | 707d2c72642b633d5ba8aa0373a272e972971535 (patch) | |
tree | 469a05db6fd14d93565dfbd2bca8dad09cb3c5cd /framework/Util/TLogRouter.php | |
parent | 08366aa35290df512784f1121ce4e26521faeae3 (diff) |
Added TFirebugLogRoute
Diffstat (limited to 'framework/Util/TLogRouter.php')
-rw-r--r-- | framework/Util/TLogRouter.php | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php index 9229001c..3a08fd63 100644 --- a/framework/Util/TLogRouter.php +++ b/framework/Util/TLogRouter.php @@ -891,5 +891,79 @@ class TDbLogRoute extends TLogRoute }
}
-
+ +/** + * TFirebugLogRoute class. + * + * TFirebugLogRoute prints selected log messages in the firebug log console. + * + * {@link http://www.getfirebug.com/ FireBug Website} + * + * @author Enrico Stahn <mail@enricostahn.com>, Christophe Boulain <Christophe.Boulain@gmail.com> + * @version $Id$ + * @package System.Util + * @since 3.1.2 + */ +class TFirebugLogRoute extends TBrowserLogRoute +{ + protected function renderHeader () + { + $string = <<<EOD + +<script type="text/javascript"> +/*<![CDATA[*/ +if (typeof(console) == 'object') +{ + console.log ("[Cumulated Time] [Time] [Level] [Category] [Message]"); + +EOD; + + return $string; + } + + protected function renderMessage ($log, $info) + { + $logfunc = $this->getFirebugLoggingFunction($log[1]); + $total = sprintf('%0.6f', $info['total']); + $delta = sprintf('%0.6f', $info['delta']); + $msg = trim($this->formatLogMessage($log[0],$log[1],$log[2],'')); + $msg = preg_replace('/\(line[^\)]+\)$/','',$msg); //remove line number info + $msg = "[{$total}] [{$delta}] ".$msg; // Add time spent and cumulated time spent + $string = $logfunc . '(\'' . addslashes($msg) . '\');' . "\n"; + + return $string; + } + + + protected function renderFooter () + { + $string = <<<EOD + +} +</script> + +EOD; + + return $string; + } + + protected function getFirebugLoggingFunction($level) + { + switch ($level) + { + case TLogger::DEBUG: + case TLogger::INFO: + case TLogger::NOTICE: + return 'console.log'; + case TLogger::WARNING: + return 'console.warn'; + case TLogger::ERROR: + case TLogger::ALERT: + case TLogger::FATAL: + return 'console.error'; + } + return 'console.log'; + } + +}
?>
\ No newline at end of file |