# Licensed for distribution under the GPL version 2, check COPYING for details
from twisted.python import log
-import sys
+import sys, time
import config
def observer(eventDict):
+ try:
+ observer2(eventDict)
+ except Exception, e:
+ printf("CRITICAL: Traceback in debug.observer2 - " + str(e))
+
+
+def observer2(eventDict):
edm = eventDict['message']
if isinstance(edm, LogEvent):
if edm.category == INFO and config.debugLevel < 3:
return
# Now log it!
- timeStr = time.strftime(self.timeFormat, time.localtime(eventDict['time']))
+ timeStr = time.strftime("[%Y-%m-%d %H:%M:%S]", time.localtime(eventDict['time']))
text = text.replace("\n", "\n\t")
global debugFile
- debugFile.write(timeStr + msgStr)
+ debugFile.write("%s %s\n" % (timeStr, text))
+ debugFile.flush()
+def printf(text):
+ sys.__stdout__.write(text + "\n")
+ sys.__stdout__.flush()
debugFile = None
def reloadConfig():