This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Example of logging.formatter with new str.format style
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, fdrake, spaceman_spiff, vinay.sajip
Priority: normal Keywords: patch

Created on 2019-04-05 05:14 by spaceman_spiff, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12693 closed python-dev, 2019-04-05 05:15
Messages (4)
msg339470 - (view) Author: (spaceman_spiff) * Date: 2019-04-05 05:14
It was not quite clear how to use the logging library with the new str.format style so I added an example in the logging cookbook
msg339504 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-04-05 15:25
But there is an example in the cookbook already:

https://docs.python.org/3/howto/logging-cookbook.html#use-of-alternative-formatting-styles

It's right there in the first code sample in that section.

You might want to amend your change to point to this section from the one where you want to make the change.
msg339513 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2019-04-05 19:07
Good catch, Vinay!  Thanks.
msg339526 - (view) Author: (spaceman_spiff) * Date: 2019-04-06 06:44
I was under the impression that this was all it takes to use loggers with the normal string.format syntax.
e.g.:
   log.info('{}', 'Test')
Turns out when I tested it I used f-strings in the first parameters - so I got it wrong.
Imho this can be closed and the pr rejected.
Sorry for wasting your time :)
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80713
2019-04-06 06:44:03spaceman_spiffsetstatus: open -> closed

messages: + msg339526
stage: patch review -> resolved
2019-04-05 19:07:11fdrakesetmessages: + msg339513
2019-04-05 15:25:32vinay.sajipsetmessages: + msg339504
2019-04-05 06:29:00xtreaksetnosy: + vinay.sajip

versions: - Python 3.5, Python 3.6, Python 3.9
2019-04-05 05:48:28fdrakesetnosy: + fdrake
2019-04-05 05:15:28python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12618
2019-04-05 05:14:22spaceman_spiffsettype: enhancement
2019-04-05 05:14:14spaceman_spiffcreate