commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r6990 - trunk/gnue-common/src/apps


From: jamest
Subject: [gnue] r6990 - trunk/gnue-common/src/apps
Date: Thu, 10 Feb 2005 14:11:26 -0600 (CST)

Author: jamest
Date: 2005-02-10 14:11:25 -0600 (Thu, 10 Feb 2005)
New Revision: 6990

Modified:
   trunk/gnue-common/src/apps/GBaseApp.py
   trunk/gnue-common/src/apps/GDebug.py
   trunk/gnue-common/src/apps/RuntimeSettings.py
Log:
support for --debug-level=1,3-5,10


Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py      2005-02-10 19:51:57 UTC (rev 
6989)
+++ trunk/gnue-common/src/apps/GBaseApp.py      2005-02-10 20:11:25 UTC (rev 
6990)
@@ -266,11 +266,11 @@
       self.run = self._debugger
 
     try:
-      GDebug.setDebug(int("%s" % self.OPTIONS['debug-level']),
+      GDebug.setDebug("%s" % self.OPTIONS['debug-level'],
           self.OPTIONS['debug-file'])
     except ValueError:
-      raise StartupError, \
-          _('The debug_level option ("-d") expects a numerical value.')
+       raise StartupError, \
+           _('The debug_level option ("-d") expects numerical values.')
 
     gDebug (1, "Python %s" % sys.version)
     gDebug (1, "Run Options: %s" % opt)

Modified: trunk/gnue-common/src/apps/GDebug.py
===================================================================
--- trunk/gnue-common/src/apps/GDebug.py        2005-02-10 19:51:57 UTC (rev 
6989)
+++ trunk/gnue-common/src/apps/GDebug.py        2005-02-10 20:11:25 UTC (rev 
6990)
@@ -31,7 +31,7 @@
 
 _fh = sys.__stderr__
 _conttest = 0
-_DEBUG_LEVEL = 0
+_DEBUG_LEVELS = []
 _DEBUGGER = None
 
 __starttime = time.time ()
@@ -58,10 +58,19 @@
     _DEBUGGER = debugger
 
 def setDebug (level, file=None):
-  global _DEBUG_LEVEL, printMesg
-  _DEBUG_LEVEL = int(level)
+  global _DEBUG_LEVELS, printMesg
 
-  if _DEBUG_LEVEL > 0:
+  levels = []
+  for entry in level.split(','):
+    values=entry.split('-')
+    if len(values) > 1:
+      levels+=range(int(values[0]),int(values[1]))
+    else:
+      levels+=[int(entry)]
+      
+  _DEBUG_LEVELS=levels
+      
+  if _DEBUG_LEVELS != []:
     printMesg = _printMesg
   if (file):
     fh = open( file, 'w' )
@@ -98,7 +107,7 @@
   pass
 
 def _printMesg (level, message, dropToDebugger = 0):
-    if ( level <= _DEBUG_LEVEL ):
+    if level in _DEBUG_LEVELS :
       global _fh, _DEBUGGER
       if type(message)==type(u''):
           message=message.encode('utf-8')
@@ -161,7 +170,7 @@
   @param level: the debug-level the message will be logged in
   """
 
-  if level > _DEBUG_LEVEL:
+  if level in _DEBUG_LEVELS:
     return
 
   # Get the caller's frame
@@ -226,7 +235,7 @@
       be in the debug-message, unless the result is not None.
   """
 
-  if level > _DEBUG_LEVEL:
+  if level in _DEBUG_LEVELS:
     return
 
   # Get the caller's frame

Modified: trunk/gnue-common/src/apps/RuntimeSettings.py
===================================================================
--- trunk/gnue-common/src/apps/RuntimeSettings.py       2005-02-10 19:51:57 UTC 
(rev 6989)
+++ trunk/gnue-common/src/apps/RuntimeSettings.py       2005-02-10 20:11:25 UTC 
(rev 6990)
@@ -83,7 +83,7 @@
 # Save the runtime settings
 #
 def saveRuntimeSettings(instance):
-  from gnue.common.apps.GDebug import _DEBUG_LEVEL
+  from gnue.common.apps.GDebug import _DEBUG_LEVELS
   if location:
     try:
       fh = open(location,'w')
@@ -100,12 +100,12 @@
       except:
         print o(u_("\nWarning: Unable to save session data to %s\n") %
                    location)
-        if _DEBUG_LEVEL:
+        if _DEBUG_LEVELS != [0]:
           raise
       fh.close()
     except:
       print o(u_("\nWarning: Unable to save session data to %s\n") % location)
-      if _DEBUG_LEVEL:
+      if _DEBUG_LEVELS != [0]:
         raise
 
 #





reply via email to

[Prev in Thread] Current Thread [Next in Thread]