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", "name": "logging",
"version": "3.0.0", "version": "3.0.3",
"description": "", "description": "",
"author": "Fabian Stamm <dev@fabianstamm.de>", "author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [], "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", "name": "@hibas123/logging",
"version": "3.0.0", "version": "3.0.3",
"description": "", "description": "",
"main": "out/index.js", "main": "out/index.js",
"types": "out/index.d.ts", "types": "out/index.d.ts",

View File

@ -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);
} }
} }
}); });

View File

@ -1,5 +1,5 @@
import { Logging as LoggingClass } from "./base.js"; import { LoggingBase } from "./base.js";
export { Logging } from "./base.js"; export { LoggingBase } 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";
@ -16,6 +16,6 @@ export {
IFormatted, IFormatted,
} from "./types.js"; } from "./types.js";
const Logging = new LoggingClass(); const Logging = new LoggingBase();
export default Logging; export default Logging;

View File

@ -1,6 +1,6 @@
import Logging from "./index.js"; 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("test");
Logging.log("i", "am", { a: "an" }, 1000); Logging.log("i", "am", { a: "an" }, 1000);