From: <bov...@us...> - 2006-05-02 20:18:23
|
Revision: 1199 Author: boverhof Date: 2006-05-02 13:18:18 -0700 (Tue, 02 May 2006) ViewCVS: http://svn.sourceforge.net/pywebsvcs/?rev=1199&view=rev Log Message: ----------- M logging.py -- added debugOn and warnOn methods Modified Paths: -------------- trunk/wstools/logging.py Modified: trunk/wstools/logging.py =================================================================== --- trunk/wstools/logging.py 2006-05-02 20:16:22 UTC (rev 1198) +++ trunk/wstools/logging.py 2006-05-02 20:18:18 UTC (rev 1199) @@ -7,7 +7,10 @@ ident = "$Id$" import sys +WARN = 1 +DEBUG = 2 + class ILogger: '''Logger interface, by default this class will be used and logging calls are no-ops. @@ -24,6 +27,10 @@ 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 @@ 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 @@ '''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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |