mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
libplugin: create debug message for notifications
Makes it easier to post-mortem in the logs. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user