From 8c89c21a89c114624ab20a8f48c304f0de3727b0 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 29 Jan 2006 05:06:04 +0000 Subject: LogRoutes now work when errors happen during application running. --- demos/personal/protected/Pages/Home.page | 2 +- demos/personal/protected/application.xml | 4 ++-- framework/Exceptions/TErrorHandler.php | 2 +- framework/Exceptions/templates/exception-en.html | 2 +- framework/Exceptions/templates/exception-fr.html | 2 +- framework/Exceptions/templates/exception-zh.html | 4 ++-- framework/Exceptions/templates/exception.html | 2 +- framework/Log/TLogRouter.php | 22 +++++++++++++--------- framework/TApplication.php | 7 +++---- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/demos/personal/protected/Pages/Home.page b/demos/personal/protected/Pages/Home.page index 9471a9b9..204d4c6f 100644 --- a/demos/personal/protected/Pages/Home.page +++ b/demos/personal/protected/Pages/Home.page @@ -1,3 +1,3 @@ - + main content \ No newline at end of file diff --git a/demos/personal/protected/application.xml b/demos/personal/protected/application.xml index 84467e98..28da6696 100644 --- a/demos/personal/protected/application.xml +++ b/demos/personal/protected/application.xml @@ -8,8 +8,8 @@ --> - - + + diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index fec4ce00..682de231 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -135,7 +135,7 @@ class TErrorHandler extends TModule else $this->handleExternalError(500,$param); } - exit(1); +// exit(1); } /** diff --git a/framework/Exceptions/templates/exception-en.html b/framework/Exceptions/templates/exception-en.html index c087792f..f9012206 100644 --- a/framework/Exceptions/templates/exception-en.html +++ b/framework/Exceptions/templates/exception-en.html @@ -12,7 +12,7 @@ h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt} p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px} -code,pre {font-family:"Lucida Console";} +code,pre {font-family:"Lucida Console";font-size:10pt;} td,.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;} .source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;} .error {background-color: #ffeeee;}/*]]>*/ diff --git a/framework/Exceptions/templates/exception-fr.html b/framework/Exceptions/templates/exception-fr.html index ee41571c..993ef39e 100644 --- a/framework/Exceptions/templates/exception-fr.html +++ b/framework/Exceptions/templates/exception-fr.html @@ -11,7 +11,7 @@ h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt} p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px} -code,pre {font-family:"Lucida Console";} +code,pre {font-family:"Lucida Console";font-size:10pt;} td,.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;} .source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;} .error {background-color: #ffeeee;} diff --git a/framework/Exceptions/templates/exception-zh.html b/framework/Exceptions/templates/exception-zh.html index e4c8cbcc..ddfe9473 100644 --- a/framework/Exceptions/templates/exception-zh.html +++ b/framework/Exceptions/templates/exception-zh.html @@ -1,4 +1,4 @@ - @@ -12,7 +12,7 @@ h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt} p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px} -code,pre {font-family:"Lucida Console";} +code,pre {font-family:"Lucida Console";font-size:10pt;} td,.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;} .source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;} .error {background-color: #ffeeee;} diff --git a/framework/Exceptions/templates/exception.html b/framework/Exceptions/templates/exception.html index c087792f..f9012206 100644 --- a/framework/Exceptions/templates/exception.html +++ b/framework/Exceptions/templates/exception.html @@ -12,7 +12,7 @@ h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt} p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px} -code,pre {font-family:"Lucida Console";} +code,pre {font-family:"Lucida Console";font-size:10pt;} td,.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;} .source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;} .error {background-color: #ffeeee;}/*]]>*/ diff --git a/framework/Log/TLogRouter.php b/framework/Log/TLogRouter.php index 3292c4d3..ef16cb67 100644 --- a/framework/Log/TLogRouter.php +++ b/framework/Log/TLogRouter.php @@ -68,7 +68,7 @@ class TLogRouter extends TModule throw new TConfigurationException('logrouter_configfile_invalid',$this->_configFile); } $this->loadConfig($config); - //$this->getApplication()->attachEventHandler('OnError',array($this,'collectLogs')); + $this->getApplication()->attachEventHandler('OnError',array($this,'collectLogs')); $this->getApplication()->attachEventHandler('OnEndRequest',array($this,'collectLogs')); } @@ -158,6 +158,7 @@ abstract class TLogRoute extends TComponent TLogger::INFO=>'Info', TLogger::NOTICE=>'Notice', TLogger::WARNING=>'Warning', + TLogger::ERROR=>'Error', TLogger::ALERT=>'Alert', TLogger::FATAL=>'Fatal' ); @@ -169,6 +170,7 @@ abstract class TLogRoute extends TComponent 'info'=>TLogger::INFO, 'notice'=>TLogger::NOTICE, 'warning'=>TLogger::WARNING, + 'error'=>TLogger::ERROR, 'alert'=>TLogger::ALERT, 'fatal'=>TLogger::FATAL ); @@ -200,7 +202,7 @@ abstract class TLogRoute extends TComponent /** * @param integer|string integer log level filter (in bits). If the value is * a string, it is assumed to be comma-separated level names. Valid level names - * include 'Error', 'Debug', 'Info', 'Notice', 'Warning', 'Error', 'Alert' and 'Fatal'. + * include 'Debug', 'Info', 'Notice', 'Warning', 'Error', 'Alert' and 'Fatal'. */ public function setLevels($levels) { @@ -604,10 +606,11 @@ class TBrowserLogRoute extends TLogRoute $string = << - +

Trace Information: $category

+   CategoryMessageFrom First(s)From Last(s) EOD; @@ -622,8 +625,8 @@ EOD; $color = $this->getColorLevel($log[1]); $msg = preg_replace('/\(line[^\)]+\)$/','',$log[0]); //remove line number info $string = << - {$log[2]}{$msg}{$total}{$delta} + +  {$log[2]}{$msg}{$total}{$delta} EOD; return $string; @@ -635,16 +638,17 @@ EOD; { case TLogger::DEBUG: return 'green'; case TLogger::INFO: return 'black'; - case TLogger::NOTICE: return 'blue'; - case TLogger::WARNING: return '#f63'; - case TLogger::ALERT: return '#c00'; + case TLogger::NOTICE: return '#3333FF'; + case TLogger::WARNING: return '#33FFFF'; + case TLogger::ERROR: return '#ff9933'; + case TLogger::ALERT: return '#ff00ff'; case TLogger::FATAL: return 'red'; } } protected function renderFooter() { - $string = ""; + $string = ""; foreach(self::$_levelValues as $name => $level) { $string .= "getColorLevel($level); diff --git a/framework/TApplication.php b/framework/TApplication.php index 80c55e44..5f5c519c 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -803,10 +803,9 @@ class TApplication extends TComponent */ public function onError($param) { - if($this->hasEventHandler('OnError')) - $this->raiseEvent('OnError',$this,$param); - else - $this->getErrorHandler()->handleError($this,$param); + Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); + $this->getErrorHandler()->handleError($this,$param); + $this->raiseEvent('OnError',$this,$param); } /** -- cgit v1.2.3