question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[REQUEST] A way to show the logger name when using RichHandler

See original GitHub issue

Have you checked the issues for a similar suggestions? Yes.

How would you improve Rich?

I would add a way to show the logger name in RichHandler. While you can use a logging.Formatter that won’t allow you to have the logger name with some color. And enabling highlight for all log messages is not really a feasible solution.

What problem does it solved for you?

It would allow me to show the logger name and have it colored with Rich.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
willmcgugancommented, Dec 29, 2020

I think there would be too many methods to satisfy everybody’s uses case. There’s four potential columns in the regular logger, that’s 4 methods to get their contents, and you would still need some way to configure the widths / alignment. What I was thinking of is a render() method which gives you complete control over how the logs are displayed.

It’s not actually that hard to write a new renderer. It would only take a few lines to create a table with your desired columns.

The next version will have the render method and a get_message method or something like it…

0reactions
willmcgugancommented, Dec 30, 2020

See changes in 9.6.0 (just released)

Read more comments on GitHub >

github_iconTop Results From Across the Web

[REQUEST] A way to show the logger name when ... - GitHub
How would you improve Rich? I would add a way to show the logger name in RichHandler. While you can use a logging.Formatter...
Read more >
Logging Handler — Rich 12.6.0 documentation
Here's an example of how to set up a rich logger: import logging from rich.logging import RichHandler FORMAT = "%(message)s" logging.
Read more >
How to use custom log handler in pytest - Stack Overflow
RichHandler from the rich library to handle all captured logs in pytest. Say I have two files, # library.py import logging logger =...
Read more >
Logging Cookbook — Python 3.11.1 documentation
StreamRequestHandler): """Handler for a streaming logging request. This basically logs the record using whatever logging policy is configured locally.
Read more >
3. Logging — Level Up Your Python - GitHub Pages
But there is a better way, if you are willing to pay the (rather ugly) cost of ... Next we get a logger,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found