[issue36532] Example of logging.formatter with new str.format style
New submission from spaceman_spiff <accounts@sgerber.de>: 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 ---------- assignee: docs@python components: Documentation messages: 339470 nosy: docs@python, spaceman_spiff priority: normal severity: normal status: open title: Example of logging.formatter with new str.format style versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Change by spaceman_spiff <accounts@sgerber.de>: ---------- type: -> enhancement _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Change by Roundup Robot <devnull@psf.upfronthosting.co.za>: ---------- keywords: +patch pull_requests: +12618 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Change by Fred L. Drake, Jr. <fdrake@gmail.com>: ---------- nosy: +fdrake _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +vinay.sajip versions: -Python 3.5, Python 3.6, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Vinay Sajip <vinay_sajip@yahoo.co.uk> added the comment: But there is an example in the cookbook already: https://docs.python.org/3/howto/logging-cookbook.html#use-of-alternative-for... 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
Fred L. Drake, Jr. <fdrake@gmail.com> added the comment: Good catch, Vinay! Thanks. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
spaceman_spiff <accounts@sgerber.de> added the comment: 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 :) ---------- stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36532> _______________________________________
participants (5)
-
Fred L. Drake, Jr.
-
Karthikeyan Singaravelan
-
Roundup Robot
-
spaceman_spiff
-
Vinay Sajip