| 1218 | } |
| 1219 | |
| 1220 | static struct command_result *json_getlog(struct command *cmd, |
| 1221 | const char *buffer, |
| 1222 | const jsmntok_t *obj UNNEEDED, |
| 1223 | const jsmntok_t * params) |
| 1224 | { |
| 1225 | struct json_stream *response; |
| 1226 | enum log_level *minlevel; |
| 1227 | struct log_book *log_book = cmd->ld->log_book; |
| 1228 | |
| 1229 | if (!param(cmd, buffer, params, |
| 1230 | p_opt_def("level", param_loglevel, &minlevel, LOG_INFORM), |
| 1231 | NULL)) |
| 1232 | return command_param_failed(); |
| 1233 | |
| 1234 | response = json_stream_success(cmd); |
| 1235 | /* Suppress logging for this stream, to not bloat io logs */ |
| 1236 | json_stream_log_suppress_for_cmd(response, cmd); |
| 1237 | json_add_timestr(response, "created_at", log_book->init_time.ts); |
| 1238 | json_add_num(response, "bytes_used", (unsigned int)ringbuf_used(log_book)); |
| 1239 | json_add_num(response, "bytes_max", sizeof(log_book->ringbuf)); |
| 1240 | json_add_log(response, log_book, NULL, *minlevel); |
| 1241 | return command_success(cmd, response); |
| 1242 | } |
| 1243 | |
| 1244 | static const struct json_command getlog_command = { |
| 1245 | "getlog", |
nothing calls this directly
no test coverage detected