lightningd: have logging include an optional node_id for each entry.

A log can have a default node_id, which can be overridden on a per-entry
basis.  This changes the format of logging, so some tests need rework.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-11-17 22:11:33 +10:30
parent 4fa7b30836
commit e433d4ddc1
23 changed files with 176 additions and 85 deletions

View File

@@ -732,9 +732,13 @@ class LightningNode(object):
'to CHANNELD_NORMAL'])
return scid
def subd_pid(self, subd):
def subd_pid(self, subd, peerid=None):
"""Get the process id of the given subdaemon, eg channeld or gossipd"""
ex = re.compile(r'lightning_{}.*: pid ([0-9]*),'.format(subd))
if peerid:
ex = re.compile(r'{}-.*lightning_{}.*: pid ([0-9]*),'
.format(peerid, subd))
else:
ex = re.compile('lightning_{}-.*: pid ([0-9]*),'.format(subd))
# Make sure we get latest one if it's restarted!
for l in reversed(self.daemon.logs):
group = ex.search(l)
@@ -1024,7 +1028,7 @@ class NodeFactory(object):
# getpeers.
if not fundchannel:
for src, dst in connections:
dst.daemon.wait_for_log('openingd-{} chan #[0-9]*: Handed peer, entering loop'.format(src.info['id']))
dst.daemon.wait_for_log(r'{}-.*lightning_openingd-chan #[0-9]*: Handed peer, entering loop'.format(src.info['id']))
return nodes
# If we got here, we want to fund channels