From c5b032598ec5d2c45563fe86e829c4cd27e2818e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 19 Jun 2022 16:44:11 +0930 Subject: [PATCH] lightningd: fix outgoing IO logging for JSONRPC. Changelog-Fixed: lightningd: `log-level` `io` shows JSONRPC output, as well as input. Signed-off-by: Rusty Russell --- lightningd/jsonrpc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 0965f193a..4f6761785 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -971,9 +971,14 @@ static struct io_plan *start_json_stream(struct io_conn *conn, struct json_connection *jcon) { /* If something has created an output buffer, start streaming. */ - if (tal_count(jcon->js_arr)) + if (tal_count(jcon->js_arr)) { + size_t len; + const char *p = json_out_contents(jcon->js_arr[0]->jout, &len); + if (len) + log_io(jcon->log, LOG_IO_OUT, NULL, "", p, len); return json_stream_output(jcon->js_arr[0], conn, stream_out_complete, jcon); + } /* Tell reader it can run next command. */ io_wake(conn);