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.

Author srs
Recipients matrixise, mcoolive, srs, vinay.sajip
Date 2018-06-29.09:56:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530266207.94.0.56676864532.issue32732@psf.upfronthosting.co.za>
In-reply-to
Content
To give you a data point, I just hit this problem. Based on the docs and common sense, I didn't expect LoggerAdapter to throw away the other extra arguments. I strongly feel that this is a bug. I cannot see how it could be desired behavior over the one proposed by mcoolive.

My use case is as follows: I'm using python with pandas to clean up a large amount of messy data and I'm using the logging framework to keep track of data consistency issues. Most of these are not critical errors, but I still need to be aware of them. I'm using 'extra' to add contextual information at different layers, like the filename when a file is read in and the column/field name when that particular column is processed. I store that data in a structured format so that I can come back to it later if needed.

I'm currently monkey patching LoggerAdapter.record to achieve the behavior mcoolive described. Specifically:

    def _LoggerAdapter_process_fixed(self: logging.LoggerAdapter, msg, kwargs):
        extra = self.extra.copy()
        extra.update(kwargs.get('extra', dict()))
        kwargs['extra'] = extra
        return msg, kwargs
    logging.LoggerAdapter.process = _LoggerAdapter_process_fixed
History
Date User Action Args
2018-06-29 09:56:48srssetrecipients: + srs, vinay.sajip, matrixise, mcoolive
2018-06-29 09:56:47srssetmessageid: <1530266207.94.0.56676864532.issue32732@psf.upfronthosting.co.za>
2018-06-29 09:56:47srslinkissue32732 messages
2018-06-29 09:56:47srscreate