threads and queues

This commit is contained in:
hg
2015-06-09 22:09:28 +02:00
parent ea0c98b4c5
commit d851a9f5dc
4 changed files with 146 additions and 61 deletions

View File

@ -1,19 +1,31 @@
from time import gmtime, strftime
class Logger(object):
@staticmethod
def log(data):
print data
if Logger.debugFlag:
print data
@staticmethod
def debugEnable():
Logger.debugFlag = True
@staticmethod
def debugDisable():
Logger.debugFlag = False
debugFlag = False
@classmethod
def log(cls, data):
t = strftime("%d %b %Y %H:%M:%S", gmtime())
with open(cls.logfile, 'a') as f:
f.write("%s %s\n" % (t, data))
if cls.debugFlag:
print data
@classmethod
def debug(cls, data):
if cls.debugFlag:
cls.log(data)
@classmethod
def debugEnable(cls):
cls.debugFlag = True
@classmethod
def debugDisable(cls):
cls.debugFlag = False
@classmethod
def openlog(cls, logfile):
cls.logfile = logfile