diff --git a/codeflash/cli_cmds/logging_config.py b/codeflash/cli_cmds/logging_config.py index e546836f..e2c3f7c6 100644 --- a/codeflash/cli_cmds/logging_config.py +++ b/codeflash/cli_cmds/logging_config.py @@ -1,4 +1,4 @@ -VERBOSE_LOGGING_FORMAT = "%(asctime)s [%(pathname)s:%(lineno)s in function %(funcName)s] %(message)s" +VERBOSE_LOGGING_FORMAT = "%(asctime)s [%(pathname)s:%(lineno)s in fn %(funcName)s] %(message)s" LOGGING_FORMAT = "[%(levelname)s] %(message)s" BARE_LOGGING_FORMAT = "%(message)s" @@ -11,9 +11,16 @@ def set_level(level: int, *, echo_setting: bool = True) -> None: from codeflash.cli_cmds.console import console + class RuleAfterLogHandler(RichHandler): + def emit(self, record: logging.LogRecord) -> None: + super().emit(record) + console.rule() + logging.basicConfig( level=level, - handlers=[RichHandler(rich_tracebacks=True, markup=False, console=console, show_path=False, show_time=False)], + handlers=[ + RuleAfterLogHandler(rich_tracebacks=True, markup=False, console=console, show_path=False, show_time=False) + ], format=BARE_LOGGING_FORMAT, ) logging.getLogger().setLevel(level) @@ -23,11 +30,12 @@ def set_level(level: int, *, echo_setting: bool = True) -> None: logging.basicConfig( format=VERBOSE_LOGGING_FORMAT, handlers=[ - RichHandler(rich_tracebacks=True, markup=False, console=console, show_path=False, show_time=False) + RuleAfterLogHandler( + rich_tracebacks=True, markup=False, console=console, show_path=False, show_time=False + ) ], force=True, ) logging.info("Verbose DEBUG logging enabled") else: logging.info("Logging level set to INFO") - console.rule()