diff --git a/packages/cactus-core/src/main/typescript/plugin-registry.ts b/packages/cactus-core/src/main/typescript/plugin-registry.ts index 1925b57b06..9ff80ed4ec 100644 --- a/packages/cactus-core/src/main/typescript/plugin-registry.ts +++ b/packages/cactus-core/src/main/typescript/plugin-registry.ts @@ -1,4 +1,9 @@ import { Optional } from "typescript-optional"; +import { + Logger, + LoggerProvider, + LogLevelDesc, +} from "@hyperledger/cactus-common"; import { ICactusPlugin, IPluginKeychain, @@ -11,6 +16,7 @@ import { * the `PluginRegistry` class instances. */ export interface IPluginRegistryOptions { + logLevel?: LogLevelDesc; plugins?: ICactusPlugin[]; } @@ -23,7 +29,13 @@ export interface IPluginRegistryOptions { * classes in place of the interfaces currently describing the plugin architecture. */ export class PluginRegistry { + public static readonly CLASS_NAME = "PluginRegistry"; public readonly plugins: ICactusPlugin[]; + public readonly log: Logger; + + public get className(): string { + return PluginRegistry.CLASS_NAME; + } constructor(public readonly options: IPluginRegistryOptions = {}) { const fnTag = `PluginRegistry#constructor()`; @@ -34,6 +46,11 @@ export class PluginRegistry { throw new TypeError(`${fnTag} options.plugins truthy but non-Array`); } this.plugins = options.plugins || []; + + const level = this.options.logLevel || "INFO"; + const label = this.className; + this.log = LoggerProvider.getOrCreate({ level, label }); + this.log.debug(`Instantiated ${this.className} OK`); } public getPlugins(): ICactusPlugin[] {