27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import * as plugins from './slclick.plugins.js';
|
|
|
|
export class SmartlogDestinationClickhouse implements plugins.smartlogInterfaces.ILogDestination {
|
|
// STATIC
|
|
public static async createAndStart(optionsArg: plugins.smartclickhouse.IClickhouseConstructorOptions) {
|
|
const destinationClickhouse = new SmartlogDestinationClickhouse(optionsArg);
|
|
await destinationClickhouse.start();
|
|
return destinationClickhouse;
|
|
}
|
|
|
|
// INSTANCE
|
|
private smartclickhouseDb: plugins.smartclickhouse.SmartClickHouseDb;
|
|
private logTable: plugins.smartclickhouse.TimeDataTable;
|
|
constructor(options: plugins.smartclickhouse.IClickhouseConstructorOptions) {
|
|
this.smartclickhouseDb = new plugins.smartclickhouse.SmartClickHouseDb(options);
|
|
}
|
|
|
|
public async start() {
|
|
await this.smartclickhouseDb.start();
|
|
this.logTable = await this.smartclickhouseDb.getTable('logs');
|
|
}
|
|
|
|
public async handleLog(logPackage: plugins.smartlogInterfaces.ILogPackage<unknown>): Promise<void> {
|
|
await this.logTable.addData(logPackage);
|
|
};
|
|
}
|