tslog/Dispatch.ts
2025-02-05 11:24:37 +01:00

24 lines
549 B
TypeScript

import { IDispatch, IDispatchConfig } from "./IDispatch";
import { ILogItem } from "./ILogItem";
import { LogLevel } from "./LogLevel";
export abstract class Dispatch implements IDispatch {
children: IDispatch[] = [];
constructor(config: IDispatchConfig = {}) { }
process(item: ILogItem): void {
this.output(item);
}
output(item: ILogItem): void {
for (const dispatch of this.children) {
dispatch.process(item);
}
}
chain(dispatch: IDispatch): Dispatch {
this.children.push(dispatch);
return this;
}
}