[pLog-svn] r5686 - in plog/trunk/class: . logger object

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Jul 19 14:24:27 EDT 2007


Author: oscar
Date: 2007-07-19 14:24:27 -0400 (Thu, 19 Jul 2007)
New Revision: 5686

Removed:
   plog/trunk/class/object/exception.class.php
Modified:
   plog/trunk/class/bootstrap.php
   plog/trunk/class/logger/LogUtil.php
Log:
The Exception class is not needed anymore as PHP5 supports them natively. The only useful method that it had has been moved to LogUtil::printStackTrace()


Modified: plog/trunk/class/bootstrap.php
===================================================================
--- plog/trunk/class/bootstrap.php	2007-07-19 18:22:10 UTC (rev 5685)
+++ plog/trunk/class/bootstrap.php	2007-07-19 18:24:27 UTC (rev 5686)
@@ -22,10 +22,6 @@
 	// load our custom lt_include method to speed up the inclusion of files
 	include( PLOG_CLASS_PATH."class/object/loader.class.php" );
     
-    // load the Exception class and set the needed error handlers for PHP 4.x
-    if(PHP_VERSION < 5)
-	    lt_include( PLOG_CLASS_PATH."class/object/exception.class.php" );
-	    
     // for performance logging purposes
     lt_include( PLOG_CLASS_PATH."class/misc/info.class.php" );    
 

Modified: plog/trunk/class/logger/LogUtil.php
===================================================================
--- plog/trunk/class/logger/LogUtil.php	2007-07-19 18:22:10 UTC (rev 5685)
+++ plog/trunk/class/logger/LogUtil.php	2007-07-19 18:24:27 UTC (rev 5686)
@@ -4,7 +4,8 @@
  * @author Su Baochen <subaochen at 126.com>
  * \ingroup logger
  */
-class LogUtil{
+class LogUtil
+{
     /**
      * format an array or object
      * for debug purpose, format the debug message
@@ -107,5 +108,33 @@
 		return $dumpedvariable;
 	}
 	
+	
+	/**
+	 * Generates a stack trace
+	 */
+	function dumpStack()
+	{
+    	if( function_exists("debug_backtrace")) {
+			$info = debug_backtrace();
+
+			print( "-- Backtrace --<br/><i>" );
+			foreach( $info as $trace ) {
+				if( ($trace["function"] != "_internalerrorhandler") && ($trace["file"] != __FILE__ )) {
+					print( $trace["file"] );
+					print( "(".$trace["line"]."): " );
+					if( isset( $trace["class"] )) {
+						if( $trace["class"] != "" )
+	   						print( $trace["class"]."." );
+	                }
+					print( $trace["function"] );
+					print( "<br/>" );
+				}
+			}
+			print( "</i>" );
+        }
+        else {
+        	print("<i>Stack trace is not available</i><br/>");
+        }
+	}		
 }
 ?>

Deleted: plog/trunk/class/object/exception.class.php
===================================================================
--- plog/trunk/class/object/exception.class.php	2007-07-19 18:22:10 UTC (rev 5685)
+++ plog/trunk/class/object/exception.class.php	2007-07-19 18:24:27 UTC (rev 5686)
@@ -1,100 +0,0 @@
-<?php
-
-	/**
-	 * \defgroup Core
-	 */
-
-	/**
-	 * \ingroup Core
-	 *
-	 * PHP Java-style definition of an Exception object.
-	 */
-	class Exception  
-	{
-
-		var $_exceptionString;
-		var $_exceptionCode;
-
-        /**
-         * Creates a new Exception.
-         *
-         * @param exceptionString Descriptive message carried by the exception
-         * @param exceptionCode Numerical error code assigned to this exception
-         */
-		function Exception( $exceptionString, $exceptionCode = 0 )
-		{
-			
-
-			$this->_exceptionString = $exceptionString;
-			$this->_exceptionCode   = $exceptionCode;
-		}
-
-		/**
-		 * Throws the exception and stops the execution, dumping some
-		 * interesting information.
-		 */
-		function throw()
-		{
-			// gather some information
-			print( "<br/><b>Exception message</b>: ".$this->_exceptionString."<br/><b>Error code</b>: ".$this->_exceptionCode."<br/>" );
-			$this->_printStackTrace();
-		}
-
-		function _printStackTrace()
-		{
-        	if( function_exists("debug_backtrace")) {
-				$info = debug_backtrace();
-
-				print( "-- Backtrace --<br/><i>" );
-				foreach( $info as $trace ) {
-					if( ($trace["function"] != "_internalerrorhandler") && ($trace["file"] != __FILE__ )) {
-						print( $trace["file"] );
-						print( "(".$trace["line"]."): " );
-						if( isset( $trace["class"] )) {
-    						if( $trace["class"] != "" )
-    	   						print( $trace["class"]."." );
-    	                }
-						print( $trace["function"] );
-						print( "<br/>" );
-					}
-				}
-				print( "</i>" );
-            }
-            else {
-            	print("<i>Stack trace is not available</i><br/>");
-            }
-		}
-	}
-
-	/**
-	 * This error handler takes care of throwing exceptions whenever an error
-	 * occurs.
-	 */
-	function _internalErrorHandler( $errorCode, $errorString )
-	{
-		$exc = new Exception( $errorString, $errorCode );
-
-		//print(var_dump(debug_backtrace()));
-
-		// we don't want the E_NOTICE errors to throw an exception...
-		if( $errorCode != E_NOTICE )
-			$exc->throw();
-	}
-
-    /**
-     * Throws an exception
-     */
-	function throw( $exception )
-	{
-		$exception->throw();
-	}
-
-	function catch( $exception )
-	{
-		print( "Exception catched!" );
-	}
-
-	// this registers our own error handler
-	$old_error_handler = set_error_handler( "_internalErrorHandler" );
-	// and now we say what we would like to see
-?>



More information about the pLog-svn mailing list