Don't add disable_logging to the string representation of the Response object unless it's set

This commit is contained in:
Fabio Manganiello 2019-03-06 02:23:01 +01:00
parent fb93aec3ec
commit f6221a798a

View file

@ -63,18 +63,22 @@ class Response(Message):
the message into a UTF-8 JSON string the message into a UTF-8 JSON string
""" """
return json.dumps({ response_dict = {
'id' : self.id, 'id' : self.id,
'type' : 'response', 'type' : 'response',
'target' : self.target if hasattr(self, 'target') else None, 'target' : self.target if hasattr(self, 'target') else None,
'origin' : self.origin if hasattr(self, 'origin') else None, 'origin' : self.origin if hasattr(self, 'origin') else None,
'_timestamp' : self.timestamp, '_timestamp' : self.timestamp,
'_disable_logging' : self.disable_logging,
'response' : { 'response' : {
'output' : self.output, 'output' : self.output,
'errors' : self.errors, 'errors' : self.errors,
}, },
}) }
if self.disable_logging:
response_dict['_disable_logging'] = self.disable_logging
return json.dumps(response_dict)
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: