Browse Source

M logging.py

-- use debugOn w/i "debug" to test if should log event.
main
Joshua Boverhof 18 years ago
parent
commit
01d6145f9c
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      logging.py

+ 3
- 4
logging.py View File

@@ -31,20 +31,18 @@ class ILogger:
debugOn = lambda self: self.level >= DEBUG debugOn = lambda self: self.level >= DEBUG
warnOn = lambda self: self.level >= WARN warnOn = lambda self: self.level >= WARN
_LoggerClass = ILogger



class BasicLogger(ILogger): class BasicLogger(ILogger):
def __init__(self, msg, out=sys.stdout): def __init__(self, msg, out=sys.stdout):
self.msg, self.out = msg, out self.msg, self.out = msg, out


def warning(self, msg, *args): def warning(self, msg, *args):
if self.level < 1: return
if self.warnOn() is False: return
print >>self, BasicLogger.WARN, self.msg, print >>self, BasicLogger.WARN, self.msg,
print >>self, msg %args print >>self, msg %args
WARN = 'WARN' WARN = 'WARN'
def debug(self, msg, *args): def debug(self, msg, *args):
if self.level < 2: return
if self.debugOn() is False: return
print >>self, BasicLogger.DEBUG, self.msg, print >>self, BasicLogger.DEBUG, self.msg,
print >>self, msg %args print >>self, msg %args
DEBUG = 'DEBUG' DEBUG = 'DEBUG'
@@ -58,6 +56,7 @@ class BasicLogger(ILogger):
''' '''
for s in args: self.out.write(s) for s in args: self.out.write(s)


_LoggerClass = BasicLogger


def setBasicLogger(): def setBasicLogger():
'''Use Basic Logger. '''Use Basic Logger.


Loading…
Cancel
Save