From 57b423625be36a9174726f08164facfe2ed22c11 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 30 Jan 2018 11:14:08 +1030 Subject: [PATCH] subd: use peer log for messages (if any). This makes much more sense when you ask for a specific peer's log. Also, we put the peerid rather than pid (). Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 6 ++---- lightningd/subd.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 7cd90e090..92ef7b23a 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -699,12 +699,10 @@ static void copy_to_parent_log(const char *prefix, const char *str, struct peer *peer) { - const char *idstr = type_to_string(peer, struct pubkey, &peer->id); if (continued) - log_add(peer->ld->log, "Peer %s: ... %s", idstr, str); + log_add(peer->ld->log, "%s ... %s", prefix, str); else - log_(peer->ld->log, level, "Peer %s: %s", idstr, str); - tal_free(idstr); + log_(peer->ld->log, level, "%s %s", prefix, str); } void populate_peer(struct lightningd *ld, struct peer *peer) diff --git a/lightningd/subd.c b/lightningd/subd.c index 92c00c264..6155b8e9e 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -625,7 +625,16 @@ static struct subd *new_subd(struct lightningd *ld, return tal_free(sd); } sd->ld = ld; - sd->log = new_log(sd, ld->log_book, "%s(%u):", name, sd->pid); + if (peer) { + /* FIXME: Use minimal unique pubkey prefix for logs! */ + const char *idstr = type_to_string(peer, struct pubkey, + &peer->id); + sd->log = new_log(sd, peer->log_book, "%s(%s):", name, idstr); + tal_free(idstr); + } else { + sd->log = new_log(sd, ld->log_book, "%s(%u):", name, sd->pid); + } + sd->name = name; sd->must_not_exit = false; sd->msgname = msgname;