Skip to content

Commit 402d27d

Browse files
committed
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 <[email protected]>
1 parent 3feee7a commit 402d27d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lightningd/peer_control.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,10 @@ static void copy_to_parent_log(const char *prefix,
699699
const char *str,
700700
struct peer *peer)
701701
{
702-
const char *idstr = type_to_string(peer, struct pubkey, &peer->id);
703702
if (continued)
704-
log_add(peer->ld->log, "Peer %s: ... %s", idstr, str);
703+
log_add(peer->ld->log, "%s ... %s", prefix, str);
705704
else
706-
log_(peer->ld->log, level, "Peer %s: %s", idstr, str);
707-
tal_free(idstr);
705+
log_(peer->ld->log, level, "%s %s", prefix, str);
708706
}
709707

710708
void populate_peer(struct lightningd *ld, struct peer *peer)

lightningd/subd.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,16 @@ static struct subd *new_subd(struct lightningd *ld,
625625
return tal_free(sd);
626626
}
627627
sd->ld = ld;
628-
sd->log = new_log(sd, ld->log_book, "%s(%u):", name, sd->pid);
628+
if (peer) {
629+
/* FIXME: Use minimal unique pubkey prefix for logs! */
630+
const char *idstr = type_to_string(peer, struct pubkey,
631+
&peer->id);
632+
sd->log = new_log(sd, peer->log_book, "%s(%s):", name, idstr);
633+
tal_free(idstr);
634+
} else {
635+
sd->log = new_log(sd, ld->log_book, "%s(%u):", name, sd->pid);
636+
}
637+
629638
sd->name = name;
630639
sd->must_not_exit = false;
631640
sd->msgname = msgname;

0 commit comments

Comments
 (0)