plugins: make log prefix the basename.

It's not perfect if they have multiple with same name, but better than number.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-12-04 13:40:23 +10:30 committed by Christian Decker
parent aa4284a35e
commit 111d6df442

View File

@ -118,18 +118,14 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
void plugin_register(struct plugins *plugins, const char* path TAKES)
{
struct plugin *p;
static size_t plugin_count = 0;
p = tal(plugins, struct plugin);
list_add_tail(&plugins->plugins, &p->list);
p->plugins = plugins;
p->cmd = tal_strdup(p, path);
p->outbuf = NULL;
/* FIXME(cdecker): Referring to plugin by their registration
number might not be that useful, come up with a naming scheme
that makes more sense. */
plugin_count++;
p->log = new_log(p, plugins->log_book, "plugin-%zu", plugin_count);
p->log = new_log(p, plugins->log_book, "plugin-%s",
path_basename(tmpctx, p->cmd));
p->methods = tal_arr(p, const char *, 0);
list_head_init(&p->plugin_opts);
}