From 6864756573f61c031b8c63bd80470d2f0b2d757f Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 4 Apr 2019 22:38:34 -0400 Subject: [PATCH] Adding close function to Logging to free resources --- package.json | 4 ++-- src/base.ts | 6 +++++- src/types.ts | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 747abc9..4c11fc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/logging", - "version": "2.0.0", + "version": "2.0.1", "description": "", "main": "out/index.js", "types": "out/index.d.ts", @@ -26,4 +26,4 @@ "dependencies": { "@hibas123/utils": "^2.0.5" } -} +} \ No newline at end of file diff --git a/src/base.ts b/src/base.ts index 3f7e125..335f265 100644 --- a/src/base.ts +++ b/src/base.ts @@ -39,7 +39,7 @@ export class LoggingBase { private messageObservable = new Observable(); protected _name: string; - + get name() { return this._name; } @@ -88,6 +88,10 @@ export class LoggingBase { } } + public close() { + this.adapter.forEach(adapter => adapter.close ? adapter.close() : undefined); + } + public waitForSetup() { return Promise.all(this.adapter_init); } diff --git a/src/types.ts b/src/types.ts index e3e0a26..25d13b6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -114,4 +114,7 @@ export interface Adapter { flush(sync: true): void; flush(sync: false): void | Promise; + + + close?(): void; } \ No newline at end of file