#35357: Logger should be able to store extra arguments
-------------------------------------+-------------------------------------
     Reporter:  Alexander Nestorov   |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Uncategorized        |                  Version:
     Severity:  Normal               |               Resolution:
     Keywords:  logging, logger,     |             Triage Stage:
  extra                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Alexander Nestorov:

Old description:

> I find myself quite often writing multiple `logger.whatever()` statements
> one after another just because I want to log multiple values.
>
> {{{
> logger.error("Foo failed. The bar object looked like")
> logger.error(bar_object) # bar_object is a deep json-like object
> logger.error(f"Retrying with {xyz} thing")
> }}}
>
> It would be nice if Django provided a way to log all values passed to
> `extra`, like this:
>
> {{{
> logger.error("Foo failed. The bar object looked like this. Retrying with
> {xyz} thing", extra={
>     "bar_object": bar_object
> })
> }}}
>
> I'm aware that I can create a custom logger inheriting from
> logging.Handler (or the several other ways this can be achieved), but
> IMHO this is such a basic features that it should be included in Django
> itself.

New description:

 I find myself quite often writing multiple `logger.whatever()` statements
 one after another just because I want to log multiple values.

 {{{
 logger.error("Foo failed. The bar object looked like")
 logger.error(bar_object) # bar_object is a deep json-like object
 logger.error(f"Retrying with {xyz} thing")
 }}}

 It would be nice if Django provided a way to log all values passed to
 `extra`, like this:

 {{{
 logger.error(f"Foo failed. The bar object looked like this. Retrying with
 {xyz} thing", extra={
     "bar_object": bar_object
 })
 }}}

 I'm aware that I can create a custom logger inheriting from
 `logging.Handler` (or the several other ways this can be achieved), but
 IMHO this is such a basic feature that it should be included in Django
 itself.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35357#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018eb2c25ea3-debbde43-3354-4a0f-9168-8ee443e944f8-000000%40eu-central-1.amazonses.com.

Reply via email to