Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

adjust logging format?#689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
KRRT7 wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromlogging-adust
Open

adjust logging format?#689

KRRT7 wants to merge1 commit intomainfromlogging-adust

Conversation

@KRRT7
Copy link
Contributor

@KRRT7KRRT7 commentedAug 26, 2025
edited by github-actionsbot
Loading

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

Relevant files
Enhancement
logging_config.py
Use custom handler for log separators                                       

codeflash/cli_cmds/logging_config.py

  • AddedRuleAfterLogHandler subclass overridingemit to call
    console.rule()
  • SwitchedbasicConfig handlers to useRuleAfterLogHandler
  • Removed standaloneconsole.rule() at end ofset_level
  • UpdatedVERBOSE_LOGGING_FORMAT wording from "function" to "fn"
+12/-4   

@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Handler Definition

RuleAfterLogHandler is defined insideset_level on each invocation, consider moving it to module level to avoid repeated class creation and improve readability.

classRuleAfterLogHandler(RichHandler):defemit(self,record:logging.LogRecord)->None:super().emit(record)console.rule()
basicConfig Usage

Multiple calls tologging.basicConfig withoutforce=True in the initial configuration may lead to handler duplication or unexpected behavior; consider consolidating configuration or usingforce=True consistently.

logging.basicConfig(level=level,handlers=[RuleAfterLogHandler(rich_tracebacks=True,markup=False,console=console,show_path=False,show_time=False)    ],format=BARE_LOGGING_FORMAT,

@KRRT7
Copy link
ContributorAuthor

new
Screenshot 2025-08-26 at 5 49 39 AM

old
Screenshot 2025-08-26 at 5 50 21 AM

@KRRT7KRRT7 requested a review froma teamAugust 26, 2025 10:50
@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                   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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@KRRT7

[8]ページ先頭

©2009-2025 Movatter.jp