diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 56a7a3162..bf9c6f57c 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ void peer_set_condition(struct peer *peer, const char *fmt, ...) tal_free(peer->condition); peer->condition = tal_vfmt(peer, fmt, ap); va_end(ap); + log_info(peer->log, "condition: %s", peer->condition); } static struct peer *new_peer(struct lightningd *ld, @@ -53,6 +55,10 @@ static struct peer *new_peer(struct lightningd *ld, peer->id = NULL; peer->fd = io_conn_fd(conn); peer->connect_cmd = cmd; + /* Max 128k per peer. */ + peer->log_book = new_log_book(peer, 128*1024, LOG_UNUSUAL); + peer->log = new_log(peer, peer->log_book, + "peer %"PRIu64":", peer->unique_id); /* FIXME: Don't assume protocol here! */ if (!netaddr_from_fd(peer->fd, SOCK_STREAM, IPPROTO_TCP, diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index b935833ac..db98e675a 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -20,6 +20,10 @@ struct peer { /* What's happening (doubles as error return for connect_cmd) */ const char *condition; + /* History */ + struct log_book *log_book; + struct log *log; + /* ID of peer (NULL before initial handshake). */ struct pubkey *id;