| 961 | } |
| 962 | |
| 963 | static struct command_result *json_getlog(struct command *cmd, |
| 964 | const char *buffer, |
| 965 | const jsmntok_t *obj UNNEEDED, |
| 966 | const jsmntok_t * params) |
| 967 | { |
| 968 | struct json_stream *response; |
| 969 | enum log_level *minlevel; |
| 970 | struct log_book *lr = cmd->ld->log_book; |
| 971 | |
| 972 | if (!param(cmd, buffer, params, |
| 973 | p_opt_def("level", param_loglevel, &minlevel, LOG_INFORM), |
| 974 | NULL)) |
| 975 | return command_param_failed(); |
| 976 | |
| 977 | response = json_stream_success(cmd); |
| 978 | /* Suppress logging for this stream, to not bloat io logs */ |
| 979 | json_stream_log_suppress_for_cmd(response, cmd); |
| 980 | json_add_time(response, "created_at", lr->init_time.ts); |
| 981 | json_add_num(response, "bytes_used", (unsigned int)lr->mem_used); |
| 982 | json_add_num(response, "bytes_max", (unsigned int)lr->max_mem); |
| 983 | json_add_log(response, lr, NULL, *minlevel); |
| 984 | return command_success(cmd, response); |
| 985 | } |
| 986 | |
| 987 | static const struct json_command getlog_command = { |
| 988 | "getlog", |
nothing calls this directly
no test coverage detected