Changing name again
This commit is contained in:
parent
96d7808f35
commit
357b98c69a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "logging",
|
"name": "logging",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
|
3844
package-lock.json
generated
3844
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/logging",
|
"name": "@hibas123/logging",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "out/index.js",
|
"main": "out/index.js",
|
||||||
"types": "out/index.d.ts",
|
"types": "out/index.d.ts",
|
||||||
|
28
src/base.ts
28
src/base.ts
@ -134,7 +134,7 @@ export abstract class LoggingInterface implements ILoggingInterface {
|
|||||||
|
|
||||||
this.#timerMap.set(id, {
|
this.#timerMap.set(id, {
|
||||||
name: id,
|
name: id,
|
||||||
start: Logging.nativeFunctions.startTimer(),
|
start: LoggingBase.nativeFunctions.startTimer(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -146,7 +146,7 @@ export abstract class LoggingInterface implements ILoggingInterface {
|
|||||||
timeEnd(id: string) {
|
timeEnd(id: string) {
|
||||||
let timer = this.#timerMap.get(id);
|
let timer = this.#timerMap.get(id);
|
||||||
if (timer) {
|
if (timer) {
|
||||||
let diff = Logging.nativeFunctions.endTimer(timer.start);
|
let diff = LoggingBase.nativeFunctions.endTimer(timer.start);
|
||||||
|
|
||||||
this.message(LoggingTypes.Debug, this.#names, [
|
this.message(LoggingTypes.Debug, this.#names, [
|
||||||
Format.green(`[${timer.name}]`),
|
Format.green(`[${timer.name}]`),
|
||||||
@ -163,13 +163,13 @@ export abstract class LoggingInterface implements ILoggingInterface {
|
|||||||
abstract getChild(name: string): ILoggingInterface;
|
abstract getChild(name: string): ILoggingInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Logging extends LoggingInterface {
|
export class LoggingBase extends LoggingInterface {
|
||||||
private static [InitialisedAdapters] = new Map<Adapter, number>();
|
private static [InitialisedAdapters] = new Map<Adapter, number>();
|
||||||
public static nativeFunctions: INativeFunctions = DefaultNativeFunctions;
|
public static nativeFunctions: INativeFunctions = DefaultNativeFunctions;
|
||||||
|
|
||||||
static DecoupledLogging = class extends LoggingInterface {
|
static DecoupledLogging = class extends LoggingInterface {
|
||||||
#lg: Logging;
|
#lg: LoggingBase;
|
||||||
constructor(names: string[], lg: Logging) {
|
constructor(names: string[], lg: LoggingBase) {
|
||||||
super(names);
|
super(names);
|
||||||
this.#lg = lg;
|
this.#lg = lg;
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ export class Logging extends LoggingInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getChild(name: string) {
|
getChild(name: string) {
|
||||||
return new Logging.DecoupledLogging([this.names, name], this.#lg);
|
return new LoggingBase.DecoupledLogging([this.names, name], this.#lg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -221,13 +221,13 @@ export class Logging extends LoggingInterface {
|
|||||||
|
|
||||||
const add = () => {
|
const add = () => {
|
||||||
this.#adapters.add(adapter);
|
this.#adapters.add(adapter);
|
||||||
if (Logging[InitialisedAdapters].has(adapter)) {
|
if (LoggingBase[InitialisedAdapters].has(adapter)) {
|
||||||
Logging[InitialisedAdapters].set(
|
LoggingBase[InitialisedAdapters].set(
|
||||||
adapter,
|
adapter,
|
||||||
Logging[InitialisedAdapters].get(adapter) + 1
|
LoggingBase[InitialisedAdapters].get(adapter) + 1
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Logging[InitialisedAdapters].set(adapter, 1);
|
LoggingBase[InitialisedAdapters].set(adapter, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ export class Logging extends LoggingInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getChild(name: string): ILoggingInterface {
|
getChild(name: string): ILoggingInterface {
|
||||||
return new Logging.DecoupledLogging([...this.names, name], this);
|
return new LoggingBase.DecoupledLogging([...this.names, name], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected message(
|
protected message(
|
||||||
@ -389,15 +389,15 @@ export class Logging extends LoggingInterface {
|
|||||||
this.#closed = true;
|
this.#closed = true;
|
||||||
|
|
||||||
this.#adapters.forEach((adapter) => {
|
this.#adapters.forEach((adapter) => {
|
||||||
const cnt = Logging[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();
|
adapter.close();
|
||||||
Logging[InitialisedAdapters].delete(adapter);
|
LoggingBase[InitialisedAdapters].delete(adapter);
|
||||||
} else {
|
} else {
|
||||||
Logging[InitialisedAdapters].set(adapter, cnt - 1);
|
LoggingBase[InitialisedAdapters].set(adapter, cnt - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Logging as LoggingClass } from "./base.js";
|
import { LoggingBase as LoggingClass } from "./base.js";
|
||||||
export { Logging } from "./base.js";
|
export { LoggingBase as Logging } from "./base.js";
|
||||||
export { ConsoleAdapter } from "./consolewriter.js";
|
export { ConsoleAdapter } from "./consolewriter.js";
|
||||||
export { ILoggingOptions, INativeFunctions } from "./base.js";
|
export { ILoggingOptions, INativeFunctions } from "./base.js";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user