irkerd: Add Target.__str__ for pretty-printing targets in log messages
authorW. Trevor King <wking@tremily.us>
Fri, 7 Mar 2014 04:21:07 +0000 (20:21 -0800)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 11 Mar 2014 04:43:46 +0000 (00:43 -0400)
Prefer the servername, falling back to the URL, falling back to
Target.__repr__().

irkerd

diff --git a/irkerd b/irkerd
index c5fc1aee6d4b31b2d08c36f578d1013b6624dc4b..bad14f96ba863774b0235eefb0361faee21ead70 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -640,6 +640,11 @@ class Target():
         if parsed.query:
             self.key = re.sub("^key=", "", parsed.query)
         self.port = int(ircport)
+
+    def __str__(self):
+        "Represent this instance as a string"
+        return self.servername or self.url or repr(self)
+
     def validate(self):
         "Raise InvalidRequest if the URL is missing a critical component"
         if not self.servername: