| 1255 | } |
| 1256 | |
| 1257 | static struct command_result *json_getlog(struct command *cmd, |
| 1258 | const char *buffer, |
| 1259 | const jsmntok_t *obj UNNEEDED, |
| 1260 | const jsmntok_t * params) |
| 1261 | { |
| 1262 | struct json_stream *response; |
| 1263 | enum log_level *minlevel; |
| 1264 | struct log_book *log_book = cmd->ld->log_book; |
| 1265 | |
| 1266 | if (!param(cmd, buffer, params, |
| 1267 | p_opt_def("level", param_getloglevel, &minlevel, LOG_INFORM), |
| 1268 | NULL)) |
| 1269 | return command_param_failed(); |
| 1270 | |
| 1271 | response = json_stream_success(cmd); |
| 1272 | /* Suppress logging for this stream, to not bloat io logs */ |
| 1273 | json_stream_log_suppress_for_cmd(response, cmd); |
| 1274 | json_add_timestr(response, "created_at", log_book->init_time.ts); |
| 1275 | json_add_num(response, "bytes_used", (unsigned int)ringbuf_used(log_book)); |
| 1276 | json_add_num(response, "bytes_max", sizeof(log_book->ringbuf)); |
| 1277 | json_add_log(response, log_book, NULL, *minlevel); |
| 1278 | return command_success(cmd, response); |
| 1279 | } |
| 1280 | |
| 1281 | static const struct json_command getlog_command = { |
| 1282 | "getlog", |
nothing calls this directly
no test coverage detected