common: new function command_log to log something about a specific command.

Needs implementations for lightningd and libplugin, since they both use this
infrastructure.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-06-23 00:34:33 +09:30
parent 3531414d18
commit e0e38c2cd5
3 changed files with 33 additions and 0 deletions

View File

@@ -631,6 +631,19 @@ bool command_check_only(const struct command *cmd)
return cmd->check;
}
void command_log(struct command *cmd, enum log_level level,
const char *fmt, ...)
{
const char *msg;
va_list ap;
va_start(ap, fmt);
msg = tal_vfmt(cmd, fmt, ap);
plugin_log(cmd->plugin, level, "JSON COMMAND %s: %s",
cmd->methodname, msg);
va_end(ap);
}
struct command_result *command_check_done(struct command *cmd)
{
assert(command_check_only(cmd));