Pass log path in as object param. modified: .gitignore modified: listfix.py modified: listfix/log.py
Brian Barto bartobrian@gmail.com
Wed, 06 Apr 2022 14:12:14 -0400
3 files changed,
7 insertions(+),
5 deletions(-)
M
listfix.py
→
listfix.py
@@ -4,9 +4,11 @@ import sys
import os from listfix import Args, DB, Email, Errors, Log, Test +listfix_dir = os.path.dirname(os.path.realpath(__file__)) + ## Get log object -log = Log() +log = Log(listfix_dir + "/listfix.log") ## Set up the exception handler@@ -15,7 +17,6 @@ er.set_exception_handler()
## Connect to DB (create DB if needed) and check tables. -listfix_dir = os.path.dirname(os.path.realpath(__file__)) db = DB(listfix_dir + "/listfix.sqlite3") ## Get args
M
listfix/log.py
→
listfix/log.py
@@ -2,13 +2,13 @@ from datetime import datetime
class Log: - def __init__(self): - self.log_file = "/tmp/listfix_log.txt" + def __init__(self, path): + self.path = path def write(self, type, txt): txt = txt.rstrip() date = datetime.now() - f = open(self.log_file, "a") + f = open(self.path, "a") f.write(f"[{type}] {date}, {txt}\n") f.close()