diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index decb926a1..e4a830d6a 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -217,7 +217,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) *code. Here we initialize the context that will keep track and control *the plugins. */ - ld->plugins = plugins_new(ld, ld->log); + ld->plugins = plugins_new(ld, ld->log_book); return ld; } diff --git a/lightningd/plugin.c b/lightningd/plugin.c index c4bea8a27..fc8a95c6e 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -56,6 +56,7 @@ struct plugins { /* Currently pending requests by their request ID */ UINTMAP(struct plugin_request *) pending_requests; struct log *log; + struct log_book *log_book; }; struct json_output { @@ -72,21 +73,29 @@ struct plugin_opt { char *value; }; -struct plugins *plugins_new(const tal_t *ctx, struct log *log){ +struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book){ struct plugins *p; p = tal(ctx, struct plugins); list_head_init(&p->plugins); - p->log = log; + p->log_book = log_book; + p->log = new_log(p, log_book, "plugin-manager"); return p; } 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); + + /* 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 = plugins->log; list_head_init(&p->plugin_opts); } diff --git a/lightningd/plugin.h b/lightningd/plugin.h index d3988a01a..96ba978cb 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -16,7 +16,7 @@ struct plugins; /** * Create a new plugins context. */ -struct plugins *plugins_new(const tal_t *ctx, struct log *log); +struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book); /** * Initialize the registered plugins. diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 2e2e3abf7..09a991a6a 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -129,7 +129,7 @@ void plugins_config(struct plugins *plugins UNNEEDED) void plugins_init(struct plugins *plugins UNNEEDED) { fprintf(stderr, "plugins_init called!\n"); abort(); } /* Generated stub for plugins_new */ -struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED) +struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED) { fprintf(stderr, "plugins_new called!\n"); abort(); } /* Generated stub for register_opts */ void register_opts(struct lightningd *ld UNNEEDED)