Steffen Schuldenzucker <steffen.schuldenzuc...@gmail.com> added the comment:
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 ---------- nosy: +srs _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32732> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com