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
1 changed files with 7 additions and 3 deletions

View File

@ -63,18 +63,22 @@ class Response(Message):
the message into a UTF-8 JSON string
"""
return json.dumps({
response_dict = {
'id' : self.id,
'type' : 'response',
'target' : self.target if hasattr(self, 'target') else None,
'origin' : self.origin if hasattr(self, 'origin') else None,
'_timestamp' : self.timestamp,
'_disable_logging' : self.disable_logging,
'response' : {
'output' : self.output,
'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: