1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-21 23:44:19 +00:00

Append to the log instead of overwriting

This commit is contained in:
Steffo 2023-04-02 23:20:15 +02:00
parent ef4df3044a
commit 59ae40d018
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -57,14 +57,14 @@ def install_general_log_handlers():
logger.setLevel("INFO") logger.setLevel("INFO")
this_log.debug("Silenced: %s", logger) this_log.debug("Silenced: %s", logger)
log_file_path = pathlib.Path("./data/logs/last_run.tsv") log_file_path = pathlib.Path("./data/logs/run.tsv")
log_directory_path = log_file_path.parent log_directory_path = log_file_path.parent
this_log.debug("Ensuring %s exists...", log_directory_path) this_log.debug("Ensuring %s exists...", log_directory_path)
log_directory_path.mkdir(parents=True, exist_ok=True) log_directory_path.mkdir(parents=True, exist_ok=True)
this_log.debug("Ensuring %s exists...", log_file_path) this_log.debug("Ensuring %s exists...", log_file_path)
open(log_file_path, "w").close() open(log_file_path, "w").close()
this_log.debug("Installing FileHandler for the __main__ logger at %s...", log_file_path) this_log.debug("Installing FileHandler for the __main__ logger at %s...", log_file_path)
file_handler = logging.FileHandler(log_file_path, mode="w") file_handler = logging.FileHandler(log_file_path, mode="a")
file_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{") file_handler.formatter = logging.Formatter("{asctime}\t{name}\t{levelname}\t{message}", style="{")
main_logger.addHandler(file_handler) main_logger.addHandler(file_handler)
this_log.debug("Installed FileHandler for the __main__ logger at %s!", log_file_path) this_log.debug("Installed FileHandler for the __main__ logger at %s!", log_file_path)