From da039a8e2e3b19a0c44b9b25f560df66f434a62a Mon Sep 17 00:00:00 2001 From: Alexej Sidorenko Date: Mon, 7 Oct 2024 22:54:08 +0200 Subject: [PATCH] issue #565 - Logfile is overwritten when parsedmarc (re)starts Do not re-write the log file if already exists. Add a log handler in "append" mode (that should be an implicit value but it's defined explicitly for the visibility). --- parsedmarc/cli.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index f1f8ec42..64fca398 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -1179,9 +1179,7 @@ def process_reports(reports_): logger.setLevel(logging.DEBUG) if opts.log_file: try: - log_file = open(opts.log_file, "w") - log_file.close() - fh = logging.FileHandler(opts.log_file) + fh = logging.FileHandler(opts.log_file, "a") formatter = logging.Formatter( "%(asctime)s - " "%(levelname)s - [%(filename)s:%(lineno)d] - %(message)s"