2022-06-26 08:35:35 +00:00
|
|
|
import * as plugins from './smartlog.plugins.js';
|
2018-03-03 12:57:55 +00:00
|
|
|
|
2018-10-30 17:56:26 +00:00
|
|
|
import { ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces';
|
2018-03-03 12:57:55 +00:00
|
|
|
|
|
|
|
export class LogRouter {
|
2018-10-30 17:56:26 +00:00
|
|
|
/**
|
|
|
|
* all log destinations
|
|
|
|
*/
|
|
|
|
private logDestinations: ILogDestination[] = [];
|
|
|
|
|
2018-06-05 18:48:14 +00:00
|
|
|
constructor() {}
|
2018-03-03 12:57:55 +00:00
|
|
|
|
2018-10-30 17:56:26 +00:00
|
|
|
public addLogDestination(logDestination: ILogDestination) {
|
|
|
|
this.logDestinations.push(logDestination);
|
|
|
|
}
|
|
|
|
|
|
|
|
// routes the log according to added logDestinations
|
2020-06-11 10:11:37 +00:00
|
|
|
public async routeLog(logPackageArg: ILogPackage) {
|
2018-10-30 17:56:26 +00:00
|
|
|
for (const logDestination of this.logDestinations) {
|
2020-06-11 10:11:37 +00:00
|
|
|
await logDestination.handleLog(logPackageArg);
|
2018-10-30 17:56:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-05 18:48:14 +00:00
|
|
|
}
|