Skip to content

Commit

Permalink
feat(logging): add Placeholder implementation (#3345)
Browse files Browse the repository at this point in the history
Refs #3197
  • Loading branch information
char0n authored Oct 31, 2023
1 parent ed60acc commit 00febde
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/apidom-logging/src/Logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface LoggerInstance {}
23 changes: 23 additions & 0 deletions packages/apidom-logging/src/Placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { LoggerInstance } from './Logger';

type LoggerHierarchyInstance = LoggerInstance | PlaceholderInstance;

export interface PlaceholderInstance {
readonly loggerMap: Map<LoggerHierarchyInstance, LoggerHierarchyInstance | null>;
append(logger: LoggerHierarchyInstance): void;
}
class Placeholder implements PlaceholderInstance {
public readonly loggerMap: Map<LoggerHierarchyInstance, LoggerHierarchyInstance | null>;

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;

0 comments on commit 00febde

Please sign in to comment.