Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Kedro logging broadcasting markup log message to all handlers. #4496

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

noklam
Copy link
Contributor

@noklam noklam commented Feb 18, 2025

Description

Development notes

  • Use "rich_format" as a Kedro specific argument to add markup language, this is only understand by Kedro.logging.RichHandler.
  • Keep the raw LogRecord and raw message without markup.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: Nok Lam Chan <[email protected]>
@noklam noklam requested a review from merelcht as a code owner February 18, 2025 15:21
@noklam noklam marked this pull request as draft February 18, 2025 15:21
Comment on lines 210 to 215
# Emit some logs
assert not custom_handler.records
catalog.save("dummy", data)
assert custom_handler.records
for record in custom_handler.records:
assert "[dark_orange]" not in record.message
Copy link
Contributor Author

@noklam noklam Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should sufficiently show that even with a dummy handler, it still capture the rich markup.
@astrojuanlu

@noklam noklam linked an issue Feb 18, 2025 that may be closed by this pull request
@noklam noklam marked this pull request as ready for review February 18, 2025 16:19
@@ -54,3 +57,20 @@ def __init__(self, *args: Any, **kwargs: Any):
# fixed on their side at some point, but until then we disable it.
# See https://github.com/Textualize/rich/issues/2455
rich.traceback.install(**traceback_install_kwargs) # type: ignore[arg-type]

def emit(self, record: LogRecord):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trick here is to keep the raw message without markup language. The handler will be responsible to add the [brackets] (I believe this is how rich.RichHandler functions anyway)

Signed-off-by: Nok Lam Chan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listen to Kedro's log without the rich markup
1 participant