all repos — listfix @ ab1a175e3797521ad31d1856bb1b9b425af4f505

Postfix Mailing List Software; Maintained on behalf the of Agency Economy Incorporated NFP.

listfix/log.py (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
from datetime import datetime

class Log:

	def __init__(self, path):
		self.path = path

	def write(self, type, txt):
		txt = txt.rstrip()
		date = datetime.now()
		f = open(self.path, "a")
		f.write(f"[{type}] {date}, {txt}\n")
		f.close()

	def info(self, txt):
		self.write("INFO", txt)

	def error(self, txt):
		self.write("ERROR", txt)

	def debug(self, txt):
		self.write("DEBUG", txt)