MCPcopy Create free account
hub / github.com/ElementsProject/lightning / log_to_json

Function log_to_json

lightningd/log.c:887–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887static 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
930void json_add_log(struct json_stream *response,
931 const struct log_book *lr,

Callers

nothing calls this directly

Calls 8

node_id_eqFunction · 0.85
add_skippedFunction · 0.85
json_object_startFunction · 0.50
json_add_stringFunction · 0.50
json_add_timeFunction · 0.50
json_add_node_idFunction · 0.50
json_add_hex_talarrFunction · 0.50
json_object_endFunction · 0.50

Tested by

no test coverage detected