]> code.delx.au - pymsnt/blobdiff - src/debug.py
Committed Remko's patches (env & typing notification fix)
[pymsnt] / src / debug.py
index fdabb20f4439ab882c6dd5f9c8eb65c61ececf28..4da2bbf14d484c435408f62bf24b50924e8d6eaa 100644 (file)
@@ -17,20 +17,20 @@ def observer(eventDict):
 def observer2(eventDict):
        edm = eventDict['message']
        if isinstance(edm, LogEvent):
-               if edm.category == INFO and config.debugLevel < 3:
+               if edm.category == INFO and config._debugLevel < 3:
                        return
-               if (edm.category == WARN or edm.category == ERROR) and config.debugLevel < 2:
+               if (edm.category == WARN or edm.category == ERROR) and config._debugLevel < 2:
                        return
                text = str(edm)
        elif edm:
-               if config.debugLevel < 3: return
+               if config._debugLevel < 3: return
                text = ' '.join(map(str, edm))
        else:
                if eventDict['isError'] and eventDict.has_key('failure'):
-                       if config.debugLevel < 1: return
+                       if config._debugLevel < 1: return
                        text = eventDict['failure'].getTraceback()
                elif eventDict.has_key('format'):
-                       if config.debugLevel < 3: return
+                       if config._debugLevel < 3: return
                        text = eventDict['format'] % eventDict
                else:
                        return
@@ -53,15 +53,16 @@ def reloadConfig():
                debugFile.close()
        
        try:
-               config.debugLevel = int(config.debugLevel)
+               config._debugLevel = int(config.debugLevel.strip())
        except ValueError:
-               config.debugLevel = 0
+               config._debugLevel = 0
+               config.debugLevel = "0"
 
-       if config.debugLevel > 0:
+       if config._debugLevel > 0:
                if len(config.debugFile) > 0:
                        try:
-                               debugFile = open(config.debugFile, "w")
-                               log.msg("Rewrote log file.")
+                               debugFile = open(config.debugFile, "a")
+                               log.msg("Reopened log file.")
                        except IOError:
                                log.discardLogs() # Give up
                                debugFile = sys.__stdout__