mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
lightningd: suppress IO_OUT logging for getlog command
Before this, the response of `getlog io` blew up quickly when called multiple times.
This commit is contained in:
parent
8feb05aef4
commit
db57d9c5d2
5 changed files with 24 additions and 0 deletions
|
@ -100,6 +100,13 @@ void json_stream_close(struct json_stream *js, struct command *writer)
|
||||||
js->writer = NULL;
|
js->writer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void json_stream_log_suppress(struct json_stream *js, const char *cmd_name)
|
||||||
|
{
|
||||||
|
/* Really shouldn't be used for anything else */
|
||||||
|
assert(streq(cmd_name, "getlog"));
|
||||||
|
js->log = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: This, or something prettier (io_replan?) belong in ccan/io! */
|
/* FIXME: This, or something prettier (io_replan?) belong in ccan/io! */
|
||||||
static void adjust_io_write(struct io_conn *conn, ptrdiff_t delta)
|
static void adjust_io_write(struct io_conn *conn, ptrdiff_t delta)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,9 @@ struct json_stream *json_stream_dup(const tal_t *ctx, struct json_stream *origin
|
||||||
*/
|
*/
|
||||||
void json_stream_close(struct json_stream *js, struct command *writer);
|
void json_stream_close(struct json_stream *js, struct command *writer);
|
||||||
|
|
||||||
|
/* For low-level JSON stream access: */
|
||||||
|
void json_stream_log_suppress(struct json_stream *js, const char *cmd_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* json_stream_still_writing - is someone currently writing to this stream?
|
* json_stream_still_writing - is someone currently writing to this stream?
|
||||||
* @js: the json_stream.
|
* @js: the json_stream.
|
||||||
|
|
|
@ -515,6 +515,16 @@ struct json_stream *json_stream_raw_for_cmd(struct command *cmd)
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void json_stream_log_suppress_for_cmd(struct json_stream *js,
|
||||||
|
const struct command *cmd)
|
||||||
|
{
|
||||||
|
const char *nm = cmd->json_cmd->name;
|
||||||
|
const char *s = tal_fmt(tmpctx, "Suppressing logging of %s command", nm);
|
||||||
|
log_io(cmd->jcon->log, LOG_IO_OUT, s, NULL, 0);
|
||||||
|
json_stream_log_suppress(js, strdup(nm));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static struct json_stream *json_start(struct command *cmd)
|
static struct json_stream *json_start(struct command *cmd)
|
||||||
{
|
{
|
||||||
struct json_stream *js = json_stream_raw_for_cmd(cmd);
|
struct json_stream *js = json_stream_raw_for_cmd(cmd);
|
||||||
|
|
|
@ -125,6 +125,8 @@ struct command_result *command_still_pending(struct command *cmd)
|
||||||
|
|
||||||
/* For low-level JSON stream access: */
|
/* For low-level JSON stream access: */
|
||||||
struct json_stream *json_stream_raw_for_cmd(struct command *cmd);
|
struct json_stream *json_stream_raw_for_cmd(struct command *cmd);
|
||||||
|
void json_stream_log_suppress_for_cmd(struct json_stream *js,
|
||||||
|
const struct command *cmd);
|
||||||
struct command_result *command_raw_complete(struct command *cmd,
|
struct command_result *command_raw_complete(struct command *cmd,
|
||||||
struct json_stream *result);
|
struct json_stream *result);
|
||||||
|
|
||||||
|
|
|
@ -766,6 +766,8 @@ static struct command_result *json_getlog(struct command *cmd,
|
||||||
return command_param_failed();
|
return command_param_failed();
|
||||||
|
|
||||||
response = json_stream_success(cmd);
|
response = json_stream_success(cmd);
|
||||||
|
/* Suppress logging for this stream, to not bloat io logs */
|
||||||
|
json_stream_log_suppress_for_cmd(response, cmd);
|
||||||
json_object_start(response, NULL);
|
json_object_start(response, NULL);
|
||||||
json_add_time(response, "created_at", log_init_time(lr)->ts);
|
json_add_time(response, "created_at", log_init_time(lr)->ts);
|
||||||
json_add_num(response, "bytes_used", (unsigned int) log_used(lr));
|
json_add_num(response, "bytes_used", (unsigned int) log_used(lr));
|
||||||
|
|
Loading…
Add table
Reference in a new issue