From 00febde261e1b8dd121d49bbb54554355344dae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Gorej?= Date: Tue, 31 Oct 2023 14:13:11 +0100 Subject: [PATCH] feat(logging): add Placeholder implementation (#3345) Refs #3197 --- packages/apidom-logging/src/Logger.ts | 1 + packages/apidom-logging/src/Placeholder.ts | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 packages/apidom-logging/src/Logger.ts create mode 100644 packages/apidom-logging/src/Placeholder.ts diff --git a/packages/apidom-logging/src/Logger.ts b/packages/apidom-logging/src/Logger.ts new file mode 100644 index 0000000000..e82a4aa0eb --- /dev/null +++ b/packages/apidom-logging/src/Logger.ts @@ -0,0 +1 @@ +export interface LoggerInstance {} diff --git a/packages/apidom-logging/src/Placeholder.ts b/packages/apidom-logging/src/Placeholder.ts new file mode 100644 index 0000000000..1714a55b97 --- /dev/null +++ b/packages/apidom-logging/src/Placeholder.ts @@ -0,0 +1,23 @@ +import type { LoggerInstance } from './Logger'; + +type LoggerHierarchyInstance = LoggerInstance | PlaceholderInstance; + +export interface PlaceholderInstance { + readonly loggerMap: Map; + append(logger: LoggerHierarchyInstance): void; +} +class Placeholder implements PlaceholderInstance { + public readonly loggerMap: Map; + + constructor(logger: LoggerHierarchyInstance) { + this.loggerMap = new Map([[logger, null]]); + } + + public append(logger: LoggerHierarchyInstance): void { + if (!this.loggerMap.has(logger)) { + this.loggerMap.set(logger, null); + } + } +} + +export default Placeholder;