diff options
author | Erik Johnston <erik@matrix.org> | 2015-02-17 15:12:06 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-02-17 15:12:06 +0000 |
commit | 4de93001bf6a7d8e770b990ea3546237b2569609 (patch) | |
tree | 8c7b0362e74731a8a852cac99f9dbfd41ba0b634 | |
parent | Format the response of transaction request in a nicer way (diff) | |
download | synapse-4de93001bf6a7d8e770b990ea3546237b2569609.tar.xz |
Make matrixfederationclient log more nicely
-rw-r--r-- | synapse/http/matrixfederationclient.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 1927948001..764b151d9a 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -16,6 +16,7 @@ from twisted.internet import defer, reactor, protocol from twisted.internet.error import DNSLookupError +from twisted.python.failure import Failure from twisted.web.client import readBody, _AgentBase, _URI from twisted.web.http_headers import Headers from twisted.web._newclient import ResponseDone @@ -146,14 +147,22 @@ class MatrixFederationHttpClient(object): ) raise SynapseError(400, "Domain specified not found.") + if hasattr(e, "reasons"): + reasons = ", ".join( + f.value.message + for f in e.reasons + ) + else: + reasons = e.message + logger.warn( - "Sending request failed to %s: %s %s : %s", + "Sending request failed to %s: %s %s: %s - %s", destination, method, url_bytes, - e + type(e). __name__, + reasons, ) - _print_ex(e) if retries_left: yield sleep(2 ** (5 - retries_left)) @@ -447,14 +456,6 @@ def _readBodyToFile(response, stream, max_size): return d -def _print_ex(e): - if hasattr(e, "reasons") and e.reasons: - for ex in e.reasons: - _print_ex(ex) - else: - logger.warn(e) - - class _JsonProducer(object): """ Used by the twisted http client to create the HTTP body from json """ |