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

ork at devel.plogworld.net ork at devel.plogworld.net
Sat Jun 11 22:03:50 GMT 2005


Author: ork
Date: 2005-06-11 22:03:49 +0000 (Sat, 11 Jun 2005)
New Revision: 2199

Modified:
   plog/trunk/class/object/object.class.php
   plog/trunk/debug.php
Log:
let us finally make use of the global DEBUG_ENABLE keyword to enable/disable debug output.
to make life easier, we implement debug channels. so if we're going to log something to the debug logfile, we can control if we want all debug messages or just specific ones.
e.g. to have just the cache log messages, write:

define( "DEBUG_CHANNELS",       DEBUG_CHANNEL_CACHE );

to have cache and sql debug messages write:

define( "DEBUG_CHANNELS",       DEBUG_CHANNEL_CACHE +
                                DEBUG_CHANNEL_SQL );

more debug channels to follow ..  

i would like to leave all the debug messages in the code. to slim a release package we might want to build a custom strip script to remove all debug if statements from all classes. 
the debug statements should look like that (e.g.):

if( DEBUG_ENABLED && DEBUG_CHANNELS & DEBUG_CHANNEL_CACHE )
    $this->debug->log("Caching $id ($group):" . $data , LOGGER_PRIO_INFO );

i guess with some simple regular expressions, we could strip all debug stuff from the code prior to a release (if neccessary).



Modified: plog/trunk/class/object/object.class.php
===================================================================
--- plog/trunk/class/object/object.class.php	2005-06-11 21:57:47 UTC (rev 2198)
+++ plog/trunk/class/object/object.class.php	2005-06-11 22:03:49 UTC (rev 2199)
@@ -58,6 +58,9 @@
 		{
 			// initialize logging -- enable this only for debugging purposes
 			$this->log =& LoggerManager::getLogger( "default" );
+
+            if( DEBUG_ENABLED )
+                $this->debug =& LoggerManager::getLogger( "debug" );
 		}
 
         function __getObjectId()

Modified: plog/trunk/debug.php
===================================================================
--- plog/trunk/debug.php	2005-06-11 21:57:47 UTC (rev 2198)
+++ plog/trunk/debug.php	2005-06-11 22:03:49 UTC (rev 2199)
@@ -13,6 +13,16 @@
       * set this to 'false' to disable all debugging output
       */
 	define( "DEBUG_ENABLED", true );
+
+    // activate debug channels, set DEBUG_CHANNELS to the channels you
+    // want to see in your debug.log
+    define( "DEBUG_CHANNEL_CONFIG", 1 );
+    define( "DEBUG_CHANNEL_CACHE",  2 );
+    define( "DEBUG_CHANNEL_SQL",    4 );
+
+    define( "DEBUG_CHANNELS",       DEBUG_CHANNEL_CACHE +
+                                    DEBUG_CHANNEL_SQL );
+
 	
 	function _debug( $params )
 	{




More information about the pLog-svn mailing list