filelogger.py
987 Bytes
import datetime
from logsystem import LogSystem
class FileLogger(LogSystem):
def __init__(self,filename):
self.file = filename
f = open(filename,"w+")
f.close()
def writeLog(self,message,module,type = None):
if(type == None):
type = self.TYPE_INFO
time = str(datetime.datetime.now())
if(type == self.TYPE_ERROR):
f = open(self.file,"a+")
f.write(time + " [" + module + "] " + "ERROR: " + message + "\n")
f.close()
elif(type == self.TYPE_WARNING):
f = open(self.file,"a+")
f.write(time + " [" + module + "] " + "WARNING: " + message + "\n")
f.close()
elif(type == self.TYPE_INFO):
f = open(self.file,"a+")
f.write(time + " [" + module + "] " + "INFO: " + message + "\n")
f.close()
else:
f = open(self.file,"a+")
f.write(message + "\n")
f.close()