Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions codeflash/cli_cmds/logging_config.py
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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)
Expand All @@ -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()
Loading