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

Function log_to_json

lightningd/log.c:1162–1200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160};
1161
1162static void log_to_json(struct timerel diff,
1163 enum log_level level,
1164 const struct node_id *node_id,
1165 const char *prefix,
1166 const char *log,
1167 size_t loglen,
1168 const u8 *io,
1169 size_t iolen,
1170 struct log_info *info)
1171{
1172 if (info->node_id) {
1173 if (!node_id || !node_id_eq(node_id, info->node_id))
1174 return;
1175 }
1176
1177 if (level < info->level) {
1178 return;
1179 }
1180
1181 json_object_start(info->response, NULL);
1182 json_add_string(info->response, "type",
1183 level == LOG_BROKEN ? "BROKEN"
1184 : level == LOG_UNUSUAL ? "UNUSUAL"
1185 : level == LOG_INFORM ? "INFO"
1186 : level == LOG_DBG ? "DEBUG"
1187 : level == LOG_TRACE ? "TRACE"
1188 : level == LOG_IO_IN ? "IO_IN"
1189 : level == LOG_IO_OUT ? "IO_OUT"
1190 : "UNKNOWN");
1191 json_add_timestr(info->response, "time", diff.ts);
1192 if (node_id)
1193 json_add_node_id(info->response, "node_id", node_id);
1194 json_add_string(info->response, "source", prefix);
1195 json_add_stringn(info->response, "log", log, loglen);
1196 if (io)
1197 json_add_hex(info->response, "data", io, iolen);
1198
1199 json_object_end(info->response);
1200}
1201
1202void json_add_log(struct json_stream *response,
1203 const struct log_book *log_book,

Callers

nothing calls this directly

Calls 8

node_id_eqFunction · 0.85
json_object_startFunction · 0.85
json_add_timestrFunction · 0.85
json_add_node_idFunction · 0.85
json_add_stringnFunction · 0.85
json_add_hexFunction · 0.85
json_object_endFunction · 0.85
json_add_stringFunction · 0.50

Tested by

no test coverage detected