Fix error with non existing close on adapter

This commit is contained in:
Fabian Stamm 2021-05-08 22:53:12 +02:00
parent 7d75f65dd3
commit 9d4e521619
3 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "logging", "name": "logging",
"version": "3.0.5", "version": "3.0.6",
"description": "", "description": "",
"author": "Fabian Stamm <dev@fabianstamm.de>", "author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [], "contributors": [],

View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/logging", "name": "@hibas123/logging",
"version": "3.0.5", "version": "3.0.6",
"description": "", "description": "",
"main": "out/index.js", "main": "out/index.js",
"types": "out/index.d.ts", "types": "out/index.d.ts",

View File

@ -373,19 +373,19 @@ export class LoggingBase extends LoggingInterface {
if (this.#closed) return; if (this.#closed) return;
this.#closed = true; this.#closed = true;
this.#adapters.forEach((adapter) => { for (const adapter of this.#adapters) {
const cnt = LoggingBase[InitialisedAdapters].get(adapter); const cnt = LoggingBase[InitialisedAdapters].get(adapter);
if (!cnt) { if (!cnt) {
//TODO: should not happen! //TODO: should not happen!
} else { } else {
if (cnt <= 1) { if (cnt <= 1) {
adapter.close(); if (adapter.close) await adapter.close();
LoggingBase[InitialisedAdapters].delete(adapter); LoggingBase[InitialisedAdapters].delete(adapter);
} else { } else {
LoggingBase[InitialisedAdapters].set(adapter, cnt - 1); LoggingBase[InitialisedAdapters].set(adapter, cnt - 1);
} }
} }
}); }
} }
} }