PR Code Suggestions ✨Explore these optional code suggestions: | Category | Suggestion | Impact | | Possible issue | Enforce basicConfig override
Addforce=True to the initialbasicConfig call so that your new handler and format are applied even if logging was configured earlier in the application. codeflash/cli_cmds/logging_config.py [19-25] logging.basicConfig( level=level, handlers=[ RuleAfterLogHandler(rich_tracebacks=True, markup=False, console=console, show_path=False, show_time=False) ], format=BARE_LOGGING_FORMAT,+ force=True, ) Suggestion importance[1-10]: 7__ Why: Addingforce=True ensures the initialbasicConfig applies the new handler and format even if logging was previously configured, improving reliability. | Medium | | General | Extract handler class to module level
Move the custom handler class to the module level to avoid redefining it on every invocation ofset_level. This reduces runtime overhead and simplifies testing. codeflash/cli_cmds/logging_config.py [14-17] +from rich.logging import RichHandler+ class RuleAfterLogHandler(RichHandler): def emit(self, record: logging.LogRecord) -> None: super().emit(record) console.rule()+def set_level(level: int, *, echo_setting: bool = True) -> None:+ import logging+ import time+ # ... rest of set_level unchanged ...+ Suggestion importance[1-10]: 6__ Why: MovingRuleAfterLogHandler outsideset_level avoids redefining the class on each call, reducing runtime overhead and improving testability. | Low | Guard console rule call
Wrap theconsole.rule() call in atry/except block to prevent any rendering errors from interrupting log emission, ensuring the handler remains resilient. codeflash/cli_cmds/logging_config.py [15-17] def emit(self, record: logging.LogRecord) -> None: super().emit(record)- console.rule()+ try:+ console.rule()+ except Exception:+ pass Suggestion importance[1-10]: 5__ Why: Wrappingconsole.rule() in a try/except prevents rendering errors from disrupting log emission, adding resilience with minimal overhead. | Low |
|
Uh oh!
There was an error while loading.Please reload this page.
User description
small improvement imo, thoughts?
PR Type
Enhancement
Description
Introduce RuleAfterLogHandler for log separators
Replace RichHandler with RuleAfterLogHandler in config
Update verbose logging format "function" → "fn"
Remove final console.rule() call
File Walkthrough
logging_config.py
Use custom handler for log separatorscodeflash/cli_cmds/logging_config.py
RuleAfterLogHandlersubclass overridingemitto callconsole.rule()basicConfighandlers to useRuleAfterLogHandlerconsole.rule()at end ofset_levelVERBOSE_LOGGING_FORMATwording from "function" to "fn"