all repos — listfix @ d0bca2d845a0d19fb5fb9f9a703550de0775a5cc

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):
		self.log_file = "/tmp/listfix_log.txt"

	def write(self, type, txt):
		txt = txt.rstrip()
		date = datetime.now()
		f = open(self.log_file, "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)