Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Clean up debug logging (#5347)
Browse files Browse the repository at this point in the history
Remove some spurious stuff, clarify some other stuff
  • Loading branch information
richvdh committed Jun 5, 2019
1 parent 016af01 commit 2615c6b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelog.d/5347.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Various improvements to debug logging.

6 changes: 5 additions & 1 deletion synapse/crypto/event_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
def check_event_content_hash(event, hash_algorithm=hashlib.sha256):
"""Check whether the hash for this PDU matches the contents"""
name, expected_hash = compute_content_hash(event.get_pdu_json(), hash_algorithm)
logger.debug("Expecting hash: %s", encode_base64(expected_hash))
logger.debug(
"Verifying content hash on %s (expecting: %s)",
event.event_id,
encode_base64(expected_hash),
)

# some malformed events lack a 'hashes'. Protect against it being missing
# or a weird type by basically treating it the same as an unhashed event.
Expand Down
4 changes: 0 additions & 4 deletions synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,6 @@ def _handle_key_deferred(verify_request):

json_object = verify_request.json_object

logger.debug(
"Got key %s %s:%s for server %s, verifying"
% (key_id, verify_key.alg, verify_key.version, server_name)
)
try:
verify_signed_json(json_object, server_name, verify_key)
except SignatureVerifyException as e:
Expand Down
16 changes: 13 additions & 3 deletions synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def get_pdu(self, destinations, event_id, room_version, outlier=False,
moving to the next destination. None indicates no timeout.
Returns:
Deferred: Results in the requested PDU.
Deferred: Results in the requested PDU, or None if we were unable to find
it.
"""

# TODO: Rate limit the number of times we try and get the same event.
Expand All @@ -257,7 +258,12 @@ def get_pdu(self, destinations, event_id, room_version, outlier=False,
destination, event_id, timeout=timeout,
)

logger.debug("transaction_data %r", transaction_data)
logger.debug(
"retrieved event id %s from %s: %r",
event_id,
destination,
transaction_data,
)

pdu_list = [
event_from_pdu_json(p, format_ver, outlier=outlier)
Expand Down Expand Up @@ -331,7 +337,11 @@ def get_state_for_room(self, destination, room_id, event_id):
)

if failed_to_fetch:
logger.warn("Failed to get %r", failed_to_fetch)
logger.warning(
"Failed to fetch missing state/auth events for %s: %s",
room_id,
failed_to_fetch
)

event_map = {
ev.event_id: ev for ev in fetched_events
Expand Down

0 comments on commit 2615c6b

Please sign in to comment.