From 38fafc7d6d8cc925309c0ffcc1cac0ab1f9298e7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 1 Jul 2021 13:59:01 +0930 Subject: [PATCH] libplugin: create debug message for notifications Makes it easier to post-mortem in the logs. Signed-off-by: Rusty Russell --- plugins/libplugin.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index f28f5be72..f1ef5b653 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -1064,15 +1064,23 @@ void plugin_notify_message(struct command *cmd, const char *fmt, ...) { va_list ap; - struct json_stream *js = plugin_notify_start(cmd, "message"); + struct json_stream *js; + const char *msg; va_start(ap, fmt); + msg = tal_vfmt(tmpctx, fmt, ap); + va_end(ap); + + /* Also log, debug level */ + plugin_log(cmd->plugin, LOG_DBG, "notify msg %s: %s", + log_level_name(level), msg); + + js = plugin_notify_start(cmd, "message"); json_add_string(js, "level", log_level_name(level)); /* In case we're OOM */ if (js->jout) - json_out_addv(js->jout, "message", true, fmt, ap); - va_end(ap); + json_out_addstr(js->jout, "message", msg); plugin_notify_end(cmd, js); }