| 885 | } |
| 886 | |
| 887 | static void log_to_json(unsigned int skipped, |
| 888 | struct timerel diff, |
| 889 | enum log_level level, |
| 890 | const struct node_id *node_id, |
| 891 | const char *prefix, |
| 892 | const char *log, |
| 893 | const u8 *io, |
| 894 | struct log_info *info) |
| 895 | { |
| 896 | info->num_skipped += skipped; |
| 897 | |
| 898 | if (info->node_id) { |
| 899 | if (!node_id || !node_id_eq(node_id, info->node_id)) |
| 900 | return; |
| 901 | } |
| 902 | |
| 903 | if (level < info->level) { |
| 904 | info->num_skipped++; |
| 905 | return; |
| 906 | } |
| 907 | |
| 908 | add_skipped(info); |
| 909 | |
| 910 | json_object_start(info->response, NULL); |
| 911 | json_add_string(info->response, "type", |
| 912 | level == LOG_BROKEN ? "BROKEN" |
| 913 | : level == LOG_UNUSUAL ? "UNUSUAL" |
| 914 | : level == LOG_INFORM ? "INFO" |
| 915 | : level == LOG_DBG ? "DEBUG" |
| 916 | : level == LOG_IO_IN ? "IO_IN" |
| 917 | : level == LOG_IO_OUT ? "IO_OUT" |
| 918 | : "UNKNOWN"); |
| 919 | json_add_time(info->response, "time", diff.ts); |
| 920 | if (node_id) |
| 921 | json_add_node_id(info->response, "node_id", node_id); |
| 922 | json_add_string(info->response, "source", prefix); |
| 923 | json_add_string(info->response, "log", log); |
| 924 | if (io) |
| 925 | json_add_hex_talarr(info->response, "data", io); |
| 926 | |
| 927 | json_object_end(info->response); |
| 928 | } |
| 929 | |
| 930 | void json_add_log(struct json_stream *response, |
| 931 | const struct log_book *lr, |
nothing calls this directly
no test coverage detected