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

Function plugin_log_handle

lightningd/plugin.c:397–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395 const jsmntok_t *paramstok)
396 WARN_UNUSED_RESULT;
397static const char *plugin_log_handle(struct plugin *plugin,
398 const jsmntok_t *paramstok)
399{
400 const jsmntok_t *msgtok, *leveltok;
401 enum log_level level;
402 bool call_notifier;
403 msgtok = json_get_member(plugin->buffer, paramstok, "message");
404 leveltok = json_get_member(plugin->buffer, paramstok, "level");
405
406 if (!msgtok || msgtok->type != JSMN_STRING) {
407 return tal_fmt(plugin, "Log notification from plugin doesn't have "
408 "a string \"message\" field");
409 }
410
411 if (!leveltok)
412 level = LOG_INFORM;
413 else if (!log_level_parse(plugin->buffer + leveltok->start,
414 leveltok->end - leveltok->start,
415 &level)
416 /* FIXME: Allow io logging? */
417 || level == LOG_IO_IN
418 || level == LOG_IO_OUT) {
419 return tal_fmt(plugin,
420 "Unknown log-level %.*s, valid values are "
421 "\"debug\", \"info\", \"warn\", or \"error\".",
422 json_tok_full_len(leveltok),
423 json_tok_full(plugin->buffer, leveltok));
424 }
425
426 call_notifier = (level == LOG_BROKEN || level == LOG_UNUSUAL)? true : false;
427 /* FIXME: Let plugin specify node_id? */
428 log_(plugin->log, level, NULL, call_notifier, "%.*s", msgtok->end - msgtok->start,
429 plugin->buffer + msgtok->start);
430 return NULL;
431}
432
433static const char *plugin_notify_handle(struct plugin *plugin,
434 const jsmntok_t *methodtok,

Callers 1

Calls 5

log_Function · 0.70
json_get_memberFunction · 0.50
log_level_parseFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected