|
|
@@ -7,6 +7,9 @@ |
|
|
|
ident = "$Id$" |
|
|
|
import sys |
|
|
|
|
|
|
|
WARN = 1 |
|
|
|
DEBUG = 2 |
|
|
|
|
|
|
|
|
|
|
|
class ILogger: |
|
|
|
'''Logger interface, by default this class |
|
|
@@ -24,6 +27,10 @@ class ILogger: |
|
|
|
def setLevel(cls, level): |
|
|
|
cls.level = level |
|
|
|
setLevel = classmethod(setLevel) |
|
|
|
|
|
|
|
debugOn = lambda self: self.level >= DEBUG |
|
|
|
warnOn = lambda self: self.level >= WARN |
|
|
|
|
|
|
|
_LoggerClass = ILogger |
|
|
|
|
|
|
|
|
|
|
@@ -33,16 +40,16 @@ class BasicLogger(ILogger): |
|
|
|
|
|
|
|
def warning(self, msg, *args): |
|
|
|
if self.level < 1: return |
|
|
|
print >>self, self.WARN, self.msg, |
|
|
|
print >>self, BasicLogger.WARN, self.msg, |
|
|
|
print >>self, msg %args |
|
|
|
WARN = 'WARN' |
|
|
|
def debug(self, msg, *args): |
|
|
|
if self.level < 2: return |
|
|
|
print >>self, self.DEBUG, self.msg, |
|
|
|
print >>self, BasicLogger.DEBUG, self.msg, |
|
|
|
print >>self, msg %args |
|
|
|
DEBUG = 'DEBUG' |
|
|
|
def error(self, msg, *args): |
|
|
|
print >>self, self.ERROR, self.msg, |
|
|
|
print >>self, BasicLogger.ERROR, self.msg, |
|
|
|
print >>self, msg %args |
|
|
|
ERROR = 'ERROR' |
|
|
|
|
|
|
@@ -62,13 +69,13 @@ def setBasicLoggerWARN(): |
|
|
|
'''Use Basic Logger. |
|
|
|
''' |
|
|
|
setLoggerClass(BasicLogger) |
|
|
|
BasicLogger.setLevel(1) |
|
|
|
BasicLogger.setLevel(WARN) |
|
|
|
|
|
|
|
def setBasicLoggerDEBUG(): |
|
|
|
'''Use Basic Logger. |
|
|
|
''' |
|
|
|
setLoggerClass(BasicLogger) |
|
|
|
BasicLogger.setLevel(2) |
|
|
|
BasicLogger.setLevel(DEBUG) |
|
|
|
|
|
|
|
def setLoggerClass(loggingClass): |
|
|
|
'''Set Logging Class. |
|
|
|