diff --git a/pyproject.toml b/pyproject.toml index 1188dc4..6db1f3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,3 +73,4 @@ yaya-benchmark = "yaya_tools.yaya_benchmark:main" yaya-inference = "yaya_tools.yaya_inference:main" yaya-augument = "yaya_tools.yaya_augument:main" yaya-inference-qt5 = "yaya_tools.yaya_inference_qt5:main" +yaya-darknet-logs-qt5 = "yaya_tools.yaya_darknet_logs_qt5:main" diff --git a/yaya_tools/yaya_logs.py b/yaya_tools/yaya_darknet_logs_qt5.py similarity index 91% rename from yaya_tools/yaya_logs.py rename to yaya_tools/yaya_darknet_logs_qt5.py index 2feac5e..35b8a97 100644 --- a/yaya_tools/yaya_logs.py +++ b/yaya_tools/yaya_darknet_logs_qt5.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import argparse +import logging import os import re import sys @@ -18,6 +19,28 @@ figure_width = 6 # Width of each figure in the layout +def logging_terminal_setup() -> None: + """ + Setup logging for the application. + + Parameters + ---------- + path_field : str + Field in the config file that contains the path to the log file. + Default is "path". + is_terminal : bool + If True, logs will be printed to the terminal. + Default is True. + """ + logging.getLogger().setLevel(logging.DEBUG) # Ensure log level is set to DEBUG + formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s") + console = logging.StreamHandler() + console.setLevel(logging.DEBUG) + console.setFormatter(formatter) + logging.getLogger().addHandler(console) + logging.info("\n\n###### Logging start of terminal session ######\n") + + # -------------------------- # Log Parsing Functions # -------------------------- @@ -260,7 +283,12 @@ def update_figures(self): # -------------------------- # Main Routine with Argparse # -------------------------- -def main(): +def main() -> None: + """ + Main function for comparing two Darknet logs and showing previews in a Qt5 window. + """ + logging_terminal_setup() + # Argument parser parser = argparse.ArgumentParser(description="Compare two Darknet logs and show previews in a Qt5 window.") parser.add_argument("--log1", type=str, default="", help="Path to log 1 file") parser.add_argument("--log2", type=str, default="", help="Path to log 2 file")