mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 01:32:34 +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:
parent
3657f26163
commit
38fafc7d6d
1 changed files with 11 additions and 3 deletions
|
@ -1064,15 +1064,23 @@ void plugin_notify_message(struct command *cmd,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
struct json_stream *js = plugin_notify_start(cmd, "message");
|
struct json_stream *js;
|
||||||
|
const char *msg;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
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));
|
json_add_string(js, "level", log_level_name(level));
|
||||||
|
|
||||||
/* In case we're OOM */
|
/* In case we're OOM */
|
||||||
if (js->jout)
|
if (js->jout)
|
||||||
json_out_addv(js->jout, "message", true, fmt, ap);
|
json_out_addstr(js->jout, "message", msg);
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
plugin_notify_end(cmd, js);
|
plugin_notify_end(cmd, js);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue