mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +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,
|
||||
const jsmntok_t *toks,
|
||||
const jsmntok_t *idtok,
|
||||
struct plugin *plugin)
|
||||
struct plugin *plugin,
|
||||
const char **disabled)
|
||||
{
|
||||
const jsmntok_t *resulttok, *dynamictok, *featurestok, *tok;
|
||||
const char *err;
|
||||
|
||||
*disabled = NULL;
|
||||
|
||||
resulttok = json_get_member(buffer, toks, "result");
|
||||
if (!resulttok || resulttok->type != JSMN_OBJECT)
|
||||
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. */
|
||||
tok = json_get_member(buffer, resulttok, "disable");
|
||||
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! */
|
||||
plugin->important = false;
|
||||
return json_strdup(plugin, buffer, tok);
|
||||
*disabled = json_strdup(plugin, buffer, tok);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dynamictok = json_get_member(buffer, resulttok, "dynamic");
|
||||
@ -1368,12 +1369,17 @@ static void plugin_manifest_cb(const char *buffer,
|
||||
const jsmntok_t *idtok,
|
||||
struct plugin *plugin)
|
||||
{
|
||||
const char *err;
|
||||
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin);
|
||||
const char *err, *disabled;
|
||||
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin, &disabled);
|
||||
|
||||
/* FIXME: log debug if it disabled *itself*! */
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1620,11 +1626,11 @@ static void plugin_config_cb(const char *buffer,
|
||||
/* Plugin can also disable itself at this stage. */
|
||||
if (json_scan(tmpctx, buffer, toks, "{result:{disable:%}}",
|
||||
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! */
|
||||
plugin->important = false;
|
||||
plugin_kill(plugin, LOG_DBG, disable);
|
||||
plugin_kill(plugin, LOG_DBG,
|
||||
"disabled itself at init: %s",
|
||||
disable);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2374,8 +2374,8 @@ def test_self_disable(node_factory):
|
||||
|
||||
# Could happen before it gets set up.
|
||||
l1.daemon.logsearch_start = 0
|
||||
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'])
|
||||
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'])
|
||||
|
||||
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']]
|
||||
|
Loading…
Reference in New Issue
Block a user