registry logger
This commit is contained in:
parent
975dd6bceb
commit
05c956ca71
@ -11,6 +11,7 @@ class Registry {
|
||||
this.endpoints = new Collection();
|
||||
this.path = options.path;
|
||||
this.server = server;
|
||||
this.logger = server.createLogger(this);
|
||||
}
|
||||
|
||||
get print () {
|
||||
@ -29,7 +30,7 @@ class Registry {
|
||||
|
||||
async loadEndpoints () {
|
||||
|
||||
const { server, endpoints } = this;
|
||||
const { server, endpoints, logger } = this;
|
||||
|
||||
return (async function read (pth) {
|
||||
|
||||
@ -44,11 +45,16 @@ class Registry {
|
||||
const Endpoint = require(file);
|
||||
if (!Endpoint) continue;
|
||||
|
||||
if (typeof Endpoint !== 'function') {
|
||||
logger.warn(`Attempted to instantiate invalid class at ${file.name}`);
|
||||
continue;
|
||||
}
|
||||
const endpoint = new Endpoint(server);
|
||||
endpoint.init();
|
||||
|
||||
if (endpoints.has(endpoint.resolveable)) throw new Error(`Error registering endpoint ${endpoint.resolveable}: an endpoint with that resolveable already exists`);
|
||||
endpoints.set(endpoint.resolveable, endpoint);
|
||||
logger.info(`Created endpoint ${endpoint.name}`);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user