Compare commits

..

2 Commits

Author SHA1 Message Date
Fabian Stamm
6daf815ea8 Change name of class 2021-05-08 22:18:44 +02:00
Fabian Stamm
357b98c69a Changing name again 2021-05-08 22:15:56 +02:00
6 changed files with 20 additions and 3864 deletions

View File

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

3844
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -134,7 +134,7 @@ export abstract class LoggingInterface implements ILoggingInterface {
this.#timerMap.set(id, {
name: id,
start: Logging.nativeFunctions.startTimer(),
start: LoggingBase.nativeFunctions.startTimer(),
});
return {
@ -146,7 +146,7 @@ export abstract class LoggingInterface implements ILoggingInterface {
timeEnd(id: string) {
let timer = this.#timerMap.get(id);
if (timer) {
let diff = Logging.nativeFunctions.endTimer(timer.start);
let diff = LoggingBase.nativeFunctions.endTimer(timer.start);
this.message(LoggingTypes.Debug, this.#names, [
Format.green(`[${timer.name}]`),
@ -163,13 +163,13 @@ export abstract class LoggingInterface implements ILoggingInterface {
abstract getChild(name: string): ILoggingInterface;
}
export class Logging extends LoggingInterface {
export class LoggingBase extends LoggingInterface {
private static [InitialisedAdapters] = new Map<Adapter, number>();
public static nativeFunctions: INativeFunctions = DefaultNativeFunctions;
static DecoupledLogging = class extends LoggingInterface {
#lg: Logging;
constructor(names: string[], lg: Logging) {
#lg: LoggingBase;
constructor(names: string[], lg: LoggingBase) {
super(names);
this.#lg = lg;
}
@ -179,7 +179,7 @@ export class Logging extends LoggingInterface {
}
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 = () => {
this.#adapters.add(adapter);
if (Logging[InitialisedAdapters].has(adapter)) {
Logging[InitialisedAdapters].set(
if (LoggingBase[InitialisedAdapters].has(adapter)) {
LoggingBase[InitialisedAdapters].set(
adapter,
Logging[InitialisedAdapters].get(adapter) + 1
LoggingBase[InitialisedAdapters].get(adapter) + 1
);
} else {
Logging[InitialisedAdapters].set(adapter, 1);
LoggingBase[InitialisedAdapters].set(adapter, 1);
}
};
@ -239,7 +239,7 @@ export class Logging extends LoggingInterface {
}
getChild(name: string): ILoggingInterface {
return new Logging.DecoupledLogging([...this.names, name], this);
return new LoggingBase.DecoupledLogging([...this.names, name], this);
}
protected message(
@ -389,15 +389,15 @@ export class Logging extends LoggingInterface {
this.#closed = true;
this.#adapters.forEach((adapter) => {
const cnt = Logging[InitialisedAdapters].get(adapter);
const cnt = LoggingBase[InitialisedAdapters].get(adapter);
if (!cnt) {
//TODO: should not happen!
} else {
if (cnt <= 1) {
adapter.close();
Logging[InitialisedAdapters].delete(adapter);
LoggingBase[InitialisedAdapters].delete(adapter);
} else {
Logging[InitialisedAdapters].set(adapter, cnt - 1);
LoggingBase[InitialisedAdapters].set(adapter, cnt - 1);
}
}
});

View File

@ -1,5 +1,5 @@
import { Logging as LoggingClass } from "./base.js";
export { Logging } from "./base.js";
import { LoggingBase } from "./base.js";
export { LoggingBase } from "./base.js";
export { ConsoleAdapter } from "./consolewriter.js";
export { ILoggingOptions, INativeFunctions } from "./base.js";
@ -16,6 +16,6 @@ export {
IFormatted,
} from "./types.js";
const Logging = new LoggingClass();
const Logging = new LoggingBase();
export default Logging;

View File

@ -1,6 +1,6 @@
import Logging from "./index.js";
import { Logging as LoggingBase, LoggingTypes, Format } from "./index.js";
import { LoggingBase, LoggingTypes, Format } from "./index.js";
Logging.log("test");
Logging.log("i", "am", { a: "an" }, 1000);