13 self.log_level = LOG_INFO
14 self.header_string = header
15 self.lock = threading.Lock()
18 now = datetime.datetime.now()
19 ts = (
"%02d:%02d:%02d.%03d" % (now.hour, now.minute, now.second, now.microsecond/1000))
20 return "%s: %s" % (self.header_string, ts)
23 self.log_level = level
31 if self.log_level < LOG_ERROR:
33 self.output(
"%s: Error: %s" % (self.header(), str))
36 if self.log_level < LOG_WARN:
38 self.output(
"%s: Warn: %s" % (self.header(), str))
41 if self.log_level < LOG_INFO:
43 self.output(
"%s: Info: %s" % (self.header(), str))
46 if self.log_level < LOG_DEBUG:
48 self.output(
"%s: Debug: %s" % (self.header(), str))
50 if __name__ ==
'__main__':
52 log.error(
'This is an error message')
53 log.warn(
'This is a warning message')
54 log.info(
'This is an info message')
55 log.debug(
'This should ** NOT ** be displayed')
56 log.set_level(LOG_ALL)
57 log.debug(
'This is a debug message')
def __init__(self, header='')
def set_level(self, level)