all repos — listfix @ 63a355332186545a1acf216d5b36253ce4d54ef5

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

Make write method handle open and close

	modified:   listfix/log.py
Brian Barto bartobrian@gmail.com
Fri, 01 Apr 2022 16:02:35 -0400
commit

63a355332186545a1acf216d5b36253ce4d54ef5

parent

18547b97d19fc759c0ec99998196c22591f477bf

1 files changed, 10 insertions(+), 10 deletions(-)

jump to
M listfix/log.pylistfix/log.py

@@ -1,19 +1,19 @@

class Log: def __init__(self): - self.log_file = open("/tmp/listfix_log.txt", "a") + self.log_file = "/tmp/listfix_log.txt" - def info(self, txt): + def write(self, type, txt): txt = txt.rstrip() - self.log_file.write(f"[INFO] {txt}\n") + f = open(self.log_file, "a") + f.write(f"[{type}] {txt}\n") + f.close() + + def info(self, txt): + self.write("INFO", txt) def error(self, txt): - txt = txt.rstrip() - self.log_file.write(f"[ERROR] {txt}\n") + self.write("ERROR", txt) def debug(self, txt): - txt = txt.rstrip() - self.log_file.write(f"[DEBUG] {txt}\n") - - def close(self): - self.log_file.close()+ self.write("DEBUG", txt)