summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-22 15:13:10 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-22 15:13:10 +0100
commitb35baf6f3c5e9f24e9af241eb2423c4b94dd5a14 (patch)
tree82a15e29a5faa1554169dd253f69359d060d41ab
parentMerge pull request #276 from matrix-org/markjh/history_for_rooms_that_have_be... (diff)
downloadsynapse-b35baf6f3c5e9f24e9af241eb2423c4b94dd5a14.tar.xz
Define __repr__ methods for StreamConfig and PaginationConfig
So that they can be used with "%r" log formats.
-rw-r--r--synapse/streams/config.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/streams/config.py b/synapse/streams/config.py
index 2ec7c5403b..167bfe0de3 100644
--- a/synapse/streams/config.py
+++ b/synapse/streams/config.py
@@ -34,6 +34,11 @@ class SourcePaginationConfig(object):
         self.direction = 'f' if direction == 'f' else 'b'
         self.limit = int(limit) if limit is not None else None
 
+    def __repr__(self):
+        return (
+            "StreamConfig(from_key=%r, to_key=%r, direction=%r, limit=%r)"
+        ) % (self.from_key, self.to_key, self.direction, self.limit)
+
 
 class PaginationConfig(object):
 
@@ -94,10 +99,10 @@ class PaginationConfig(object):
             logger.exception("Failed to create pagination config")
             raise SynapseError(400, "Invalid request.")
 
-    def __str__(self):
+    def __repr__(self):
         return (
-            "<PaginationConfig from_tok=%s, to_tok=%s, "
-            "direction=%s, limit=%s>"
+            "PaginationConfig(from_tok=%r, to_tok=%r,"
+            " direction=%r, limit=%r)"
         ) % (self.from_token, self.to_token, self.direction, self.limit)
 
     def get_source_config(self, source_name):