You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the FluentHandler class for Python logging module. I was hoping to pass a json string to the logger and have it interpreted as json, which it does, but the FluentRecordFormatter doesn't merge logged arguments in.
Adding some more context to this. In the call to format(), the code does call the underlying implementation of record.getMessage
def format(self, record):
# Compute attributes handled by parent class.
super(FluentRecordFormatter, self).format(record) # <------ record.messge = record.msg % record.args
# Add ours
record.hostname = self.hostname
# Apply format
data = self._formatter(record)
self._structuring(data, record)
return data
which does the merge, however the call to self._structuring() eventually loads the json from the msg property, not the message property which is the merged value. e.g.
I'm using the
FluentHandler
class for Python logging module. I was hoping to pass a json string to the logger and have it interpreted as json, which it does, but theFluentRecordFormatter
doesn't merge logged arguments in.Example
Expected result
Actual result
I expected the arguments to be merged in based on the behaviour of the default Python formatter which calls
record.getMessage
which merges in argumentsHowever, the behaviour of the
FluentRecordFormatter
is tojson.loads(str(msg))
the message, and ignore any arguments.Would it be suitable to merge in the arguments when loading the json? I'd be happy to contribute a PR for it. Here's a test that would cover it.
The text was updated successfully, but these errors were encountered: