From: Brian Warner Date: Sun, 3 Dec 2006 03:27:50 +0000 (-0700) Subject: make logging multiple nodes at once easier to follow X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~490 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/rgr-080307.php?a=commitdiff_plain;h=7494837e2b89598fe2d77decd6c118ee29e5712b;p=tahoe-lafs%2Ftahoe-lafs.git make logging multiple nodes at once easier to follow --- diff --git a/allmydata/client.py b/allmydata/client.py index 641b2e43..d9e16a14 100644 --- a/allmydata/client.py +++ b/allmydata/client.py @@ -46,7 +46,7 @@ class Client(node.Node, Referenceable): if self.queen_connector: return if not self.queen_pburl: - log.msg("no queen_pburl, cannot connect") + self.log("no queen_pburl, cannot connect") return self.queen_connector = self.tub.connectTo(self.queen_pburl, self._got_queen) @@ -58,14 +58,14 @@ class Client(node.Node, Referenceable): return service.MultiService.stopService(self) def _got_queen(self, queen): - log.msg("connected to queen") + self.log("connected to queen") self.queen = queen queen.notifyOnDisconnect(self._lost_queen) queen.callRemote("hello", nodeid=self.nodeid, node=self, pburl=self.my_pburl) def _lost_queen(self): - log.msg("lost connection to queen") + self.log("lost connection to queen") self.queen = None def remote_get_service(self, name): @@ -75,25 +75,25 @@ class Client(node.Node, Referenceable): for nodeid, pburl in new_peers: if nodeid == self.nodeid: continue - log.msg("adding peer %s" % idlib.b2a(nodeid)) + self.log("adding peer %s" % idlib.b2a(nodeid)) if nodeid in self.all_peers: log.msg("weird, I already had an entry for them") self.all_peers.add(nodeid) if nodeid not in self.connections: d = self.tub.getReference(pburl) def _got_reference(ref): - log.msg("connected to %s" % idlib.b2a(nodeid)) + self.log("connected to %s" % idlib.b2a(nodeid)) if nodeid in self.all_peers: self.connections[nodeid] = ref d.addCallback(_got_reference) def remote_lost_peers(self, lost_peers): for nodeid in lost_peers: - log.msg("lost peer %s" % idlib.b2a(nodeid)) + self.log("lost peer %s" % idlib.b2a(nodeid)) if nodeid in self.all_peers: self.all_peers.remove(nodeid) else: - log.msg("weird, I didn't have an entry for them") + self.log("weird, I didn't have an entry for them") if nodeid in self.connections: del self.connections[nodeid] diff --git a/allmydata/node.py b/allmydata/node.py index 7a0d28ad..1af8a3c3 100644 --- a/allmydata/node.py +++ b/allmydata/node.py @@ -29,6 +29,7 @@ class Node(service.MultiService): f.write(self.tub.getCertData()) f.close() self.nodeid = idlib.a2b(self.tub.tubID) + self.short_nodeid = self.tub.tubID[:4] # ready for printing portnum = 0 assert self.PORTNUMFILE, "Your node.Node subclass must provide PORTNUMFILE" self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE) @@ -48,7 +49,10 @@ class Node(service.MultiService): from allmydata import manhole m = manhole.AuthorizedKeysManhole(portnum, keyfile) m.setServiceParent(self) - log.msg("AuthorizedKeysManhole listening on %d" % portnum) + self.log("AuthorizedKeysManhole listening on %d" % portnum) + + def log(self, msg): + log.msg(self.short_nodeid + ": " + msg) def _setup_tub(self, local_ip): # we can't get a dynamically-assigned portnum until our Tub is @@ -84,4 +88,4 @@ class Node(service.MultiService): local_ip = get_local_ip_for() self._setup_tub(local_ip) self.tub_ready() - log.msg("%s running" % self.NODETYPE) + self.log("%s running" % self.NODETYPE) diff --git a/allmydata/queen.py b/allmydata/queen.py index dfb299d0..1c84889f 100644 --- a/allmydata/queen.py +++ b/allmydata/queen.py @@ -34,7 +34,7 @@ class Roster(service.MultiService, Referenceable): new_peers=[(new_nodeid, new_node_pburl)]) def _lost_node(self, nodeid): - log.msg("lost contact with %s" % idlib.b2a(nodeid)) + log.msg("roster: lost contact with %s" % idlib.b2a(nodeid)) del self.phonebook[nodeid] del self.connections[nodeid] eventually(self._announce_lost_peer, nodeid) @@ -57,7 +57,7 @@ class Queen(node.Node): def tub_ready(self): r = self.add_service(Roster()) self.urls["roster"] = self.tub.registerReference(r, "roster") - log.msg(" roster is at %s" % self.urls["roster"]) + self.log(" roster is at %s" % self.urls["roster"]) f = open(os.path.join(self.basedir, "roster_pburl"), "w") f.write(self.urls["roster"] + "\n") f.close()