lightningd: use jcon logging for commands where possible.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-09-13 09:57:43 +09:30
parent caecd1ee0a
commit bbe1711e16
5 changed files with 15 additions and 2 deletions

View File

@ -1251,7 +1251,7 @@ static struct command_result *json_invoice(struct command *cmd,
req = jsonrpc_request_start(info, "listincoming",
cmd->id,
cmd->ld->log,
command_log(cmd),
NULL, listincoming_done,
info);
jsonrpc_request_end(req);

View File

@ -145,6 +145,13 @@ static void destroy_jcon(struct json_connection *jcon)
tal_free(jcon->log);
}
struct log *command_log(struct command *cmd)
{
if (cmd->jcon)
return cmd->jcon->log;
return cmd->ld->log;
}
static struct command_result *json_help(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,

View File

@ -138,6 +138,9 @@ void json_stream_log_suppress_for_cmd(struct json_stream *js,
struct command_result *command_raw_complete(struct command *cmd,
struct json_stream *result);
/* Logging point to use for this command (usually, the JSON connection). */
struct log *command_log(struct command *cmd);
/* To return if param() fails. */
extern struct command_result *command_param_failed(void)
WARN_UNUSED_RESULT;

View File

@ -213,7 +213,7 @@ static struct command_result *json_checkmessage(struct command *cmd,
can->cmd = cmd;
req = jsonrpc_request_start(cmd, "listnodes",
cmd->id,
cmd->ld->log,
command_log(cmd),
NULL, listnodes_done,
can);
json_add_node_id(req->stream, "id", &can->id);

View File

@ -136,6 +136,9 @@ struct command_result *command_failed(struct command *cmd UNNEEDED,
/* Generated stub for command_its_complicated */
struct command_result *command_its_complicated(const char *why UNNEEDED)
{ fprintf(stderr, "command_its_complicated called!\n"); abort(); }
/* Generated stub for command_log */
struct log *command_log(struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_log called!\n"); abort(); }
/* Generated stub for command_param_failed */
struct command_result *command_param_failed(void)