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

[Bug? Docs?] It's not obvious from the docs how to disable highlighting when using RichHandler #3376

Open
1 of 2 tasks
MatrixManAtYrService opened this issue Jun 8, 2024 · 2 comments

Comments

@MatrixManAtYrService
Copy link

  • I've checked docs and closed issues for possible solutions.
  • I can't find my issue in the FAQ.
    (I found it, but there's more to it)

Describe the bug

I noticed unexpected splotches of green in my log ouput using RichHandler.
Screenshot from 2024-06-08 15-03-53

I see that the FAQ says I need to disable highlighting. The initializer for RichHandler does this, however:

HIGHLIGHTER_CLASS: ClassVar[Type[Highlighter]] = ReprHighlighter
...
self.highlighter = highlighter or self.HIGHLIGHTER_CLASS()

So setting highlighter to None doesn't disable it. Eventually I settled on this:

RichHandler(highlighter=NullHighlighter())

...which works just fine

This would be easier to work with if either the default value for the kwarg was ReprHighlighter, and setting it to None effectively disabled the highlighter. Or, if that's undesirable for some reason, if the use of NullHighligher with RichHandler was documented in the "how to disable" section here: https://rich.readthedocs.io/en/latest/highlighting.html

Platform
MacOS
rich==13.7.1

Copy link

github-actions bot commented Jun 8, 2024

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@Jannchie
Copy link

I also found this very confusing. Initially, I tried to provide a console without highlighter, but none of them worked:

console = Console(highlighter=None) # not work
console = Console(highlighter=NullHighlighter()) # not work
RichHandler(console=console)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants