Set a local format for a bind logger
See original GitHub issueHi, in some methods of a class I need to always log a set of values together with the message. But this should happen only in those methods. I think the bind
method is the answer, but I can’t figure out how to format the message locally.
def f(i):
context_logger = logger.bind(i=i)
context_logger.info("Starting")
...
context_logger.info("Ending")
Where to put the format for context_logger
only without altering any other parameter?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Logging Cookbook — Python 3.11.1 documentation
setLevel(logging.INFO) # set a format which is simpler for console use formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message ...
Read more >Enabling logging in BIND
Create a log directory. On SOA (soa.grpX):. Create the log directory: $ sudo mkdir -p /var/log/bind $ sudo chown bind /var/log/bind ...
Read more >Binding without creating a new logger #53 - Delgan/loguru
I'm wondering if we can have new APIs that can bind and unbind structured arguments in place (i.e. without creating a new logger)....
Read more >BIND Logging - some basic recommendations
Included in this article is a sample logging configuration. BIND ... BIND's dynamic logging channel severity setting can be used to flexibly ...
Read more >7.5. Logging in BIND 8 and 9
BIND 4 had an extensive logging system, writing information to a debug file and ... TIP: You can configure a channel to log...
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 FreeTop 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
Top GitHub Comments
I just came to realization that you can use
patch()
also.Be aware not to use it with
opt(colors=True)
because colorization won’t work due to implementation details.Thanks for the clarification. Currently, there is no easy way to achieve this. A possible workaround is to create a small utility function, although I agree this is not very satisfying.
This is an interesting use case, though. It’s definitely something that should be possible in the future as I plan to make the message formatting customizable (see #318).