mqttClock/logger.py
Wolfgang Hottgenroth 53e75d98c1 initial
2016-07-11 21:07:30 +02:00

32 lines
648 B
Python

from time import gmtime, strftime
class Logger(object):
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