[help] How to print functin name on the right hand side during logging
See original GitHub issueFrom docs (https://rich.readthedocs.io/en/latest/logging.html#logging-handler):
import logging
from rich.logging import RichHandler
FORMAT = "%(message)s"
logging.basicConfig(
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)
log = logging.getLogger("rich")
def main():
log.info("Hello, World!")
main()
Has following output:

Instead of the filename could I have the function name on the right hand side as:
[11:53:44] INFO Hello, World! main():31
or filename along with the function name:
[11:53:44] INFO Hello, World! doo.py:main():31
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
How to include the function name into logging - Stack Overflow
Just use %(funcName)s , as documented here.
Read more >Python Logging Guide - Best Practices and Hands-on Examples
The name argument in the factory function is typically a dot-separated hierarchical name, e.g., a.b.c. This naming convention enables the ...
Read more >DON'T use Print for logging | How to Log messages in Python
I hope this video was helpful and gives you a good understanding of how to log messages in python using logging module. ·...
Read more >Your Guide to the Python print() Function
In this step-by-step tutorial, you'll learn about the print() function in Python and discover some of its lesser-known features.
Read more >Python Logging Levels Explained - LogicMonitor
The functions contained in this module are designed to allow developers to log to different destinations. This is done by defining specific handlers...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@avatar-lavventura Something along the lines of:
I get:
which I believe is what you want. I believe the hyperlink in the filename/function name also will work, but my shell does not support it to test.
I think this is a little gross. +1 for the extensibility mentioned in https://github.com/Textualize/rich/pull/1705#issuecomment-984904009