mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugin: log self-disable at debug level, other manifest fails at unusual.
This avoids spamming the logs. We also remove the duplicate debug logs on self-disable (plugin_kill logs it for us). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a9aad0da98
commit
171af7742a
@ -1248,11 +1248,14 @@ static void plugin_manifest_timeout(struct plugin *plugin)
|
|||||||
static const char *plugin_parse_getmanifest_response(const char *buffer,
|
static const char *plugin_parse_getmanifest_response(const char *buffer,
|
||||||
const jsmntok_t *toks,
|
const jsmntok_t *toks,
|
||||||
const jsmntok_t *idtok,
|
const jsmntok_t *idtok,
|
||||||
struct plugin *plugin)
|
struct plugin *plugin,
|
||||||
|
const char **disabled)
|
||||||
{
|
{
|
||||||
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
|
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
|
||||||
const char *err;
|
const char *err;
|
||||||
|
|
||||||
|
*disabled = NULL;
|
||||||
|
|
||||||
resulttok = json_get_member(buffer, toks, "result");
|
resulttok = json_get_member(buffer, toks, "result");
|
||||||
if (!resulttok || resulttok->type != JSMN_OBJECT)
|
if (!resulttok || resulttok->type != JSMN_OBJECT)
|
||||||
return tal_fmt(plugin, "Invalid/missing result tok in '%.*s'",
|
return tal_fmt(plugin, "Invalid/missing result tok in '%.*s'",
|
||||||
@ -1262,12 +1265,10 @@ static const char *plugin_parse_getmanifest_response(const char *buffer,
|
|||||||
/* Plugin can disable itself: returns why it's disabled. */
|
/* Plugin can disable itself: returns why it's disabled. */
|
||||||
tok = json_get_member(buffer, resulttok, "disable");
|
tok = json_get_member(buffer, resulttok, "disable");
|
||||||
if (tok) {
|
if (tok) {
|
||||||
log_debug(plugin->log, "disabled itself: %.*s",
|
|
||||||
json_tok_full_len(tok),
|
|
||||||
json_tok_full(buffer, tok));
|
|
||||||
/* Don't get upset if this was a built-in! */
|
/* Don't get upset if this was a built-in! */
|
||||||
plugin->important = false;
|
plugin->important = false;
|
||||||
return json_strdup(plugin, buffer, tok);
|
*disabled = json_strdup(plugin, buffer, tok);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamictok = json_get_member(buffer, resulttok, "dynamic");
|
dynamictok = json_get_member(buffer, resulttok, "dynamic");
|
||||||
@ -1368,12 +1369,17 @@ static void plugin_manifest_cb(const char *buffer,
|
|||||||
const jsmntok_t *idtok,
|
const jsmntok_t *idtok,
|
||||||
struct plugin *plugin)
|
struct plugin *plugin)
|
||||||
{
|
{
|
||||||
const char *err;
|
const char *err, *disabled;
|
||||||
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin);
|
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin, &disabled);
|
||||||
|
|
||||||
/* FIXME: log debug if it disabled *itself*! */
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plugin_kill(plugin, LOG_INFORM, "%s", err);
|
plugin_kill(plugin, LOG_UNUSUAL, "%s", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disabled) {
|
||||||
|
plugin_kill(plugin, LOG_DBG,
|
||||||
|
"disabled itself: %s", disabled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1620,11 +1626,11 @@ static void plugin_config_cb(const char *buffer,
|
|||||||
/* Plugin can also disable itself at this stage. */
|
/* Plugin can also disable itself at this stage. */
|
||||||
if (json_scan(tmpctx, buffer, toks, "{result:{disable:%}}",
|
if (json_scan(tmpctx, buffer, toks, "{result:{disable:%}}",
|
||||||
JSON_SCAN_TAL(tmpctx, json_strdup, &disable)) == NULL) {
|
JSON_SCAN_TAL(tmpctx, json_strdup, &disable)) == NULL) {
|
||||||
log_debug(plugin->log, "disabled itself at init: %s",
|
|
||||||
disable);
|
|
||||||
/* Don't get upset if this was a built-in! */
|
/* Don't get upset if this was a built-in! */
|
||||||
plugin->important = false;
|
plugin->important = false;
|
||||||
plugin_kill(plugin, LOG_DBG, disable);
|
plugin_kill(plugin, LOG_DBG,
|
||||||
|
"disabled itself at init: %s",
|
||||||
|
disable);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2374,8 +2374,8 @@ def test_self_disable(node_factory):
|
|||||||
|
|
||||||
# Could happen before it gets set up.
|
# Could happen before it gets set up.
|
||||||
l1.daemon.logsearch_start = 0
|
l1.daemon.logsearch_start = 0
|
||||||
l1.daemon.wait_for_logs(['test_selfdisable_after_getmanifest: disabled itself: "Self-disable test after getmanifest"',
|
l1.daemon.wait_for_logs(['test_selfdisable_after_getmanifest: .* disabled itself: Self-disable test after getmanifest',
|
||||||
'test_libplugin: disabled itself at init: Disabled via selfdisable option'])
|
'test_libplugin: .* disabled itself at init: Disabled via selfdisable option'])
|
||||||
|
|
||||||
assert p1 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
|
assert p1 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
|
||||||
assert p2 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
|
assert p2 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
|
||||||
|
Loading…
Reference in New Issue
Block a user