Wolfgang Hottgenroth 3fcf6fe486 initial
2017-11-10 22:03:30 +01:00

37 lines
793 B
Python

from time import gmtime, strftime
class Logger(object):
debugFlag = False
debugToStdoutFlag = 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 and cls.debugToStdoutFlag:
print data
@classmethod
def debug(cls, data):
if cls.debugFlag:
cls.log(data)
@classmethod
def debugEnable(cls):
cls.debugFlag = True
@classmethod
def debugToStdoutEnable(cls):
cls.debugToStdoutFlag = True
@classmethod
def debugDisable(cls):
cls.debugFlag = False
@classmethod
def openlog(cls, logfile):
cls.logfile = logfile