From 92b12eaacfc707d04bfdfbe637a545e2a6778358 Mon Sep 17 00:00:00 2001 From: Alexej Sidorenko Date: Thu, 10 Oct 2024 21:27:15 +0200 Subject: [PATCH] issue #565 - Logfile is overwritten when parsedmarc (re)starts (#569) 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"