diff --git a/package.json b/package.json index 2e52097..7b0c8e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/logging", - "version": "4.0.2", + "version": "4.0.4", "description": "", "type": "module", "main": "esm/index.js", diff --git a/src/base.ts b/src/base.ts index ba6d766..2837171 100644 --- a/src/base.ts +++ b/src/base.ts @@ -139,17 +139,17 @@ export abstract class LoggingInterface implements ILoggingInterface { mark: (label: string) => { timer.marks.push({ time: LoggingBase.nativeFunctions.startTimer(), name: label }); }, - end: () => this.timeEnd(id), + end: (level?: LoggingTypes) => this.timeEnd(id, level), }; } - timeEnd(id: string) { + timeEnd(id: string, level: LoggingTypes = LoggingTypes.Debug): number { let timer = this.#timerMap.get(id); if (timer) { let end_time = LoggingBase.nativeFunctions.startTimer(); let diff = LoggingBase.nativeFunctions.diffTime(timer.start, end_time); - this.message(LoggingTypes.Debug, this.#names, [ + this.message(level, this.#names, [ Format.green(`[${timer.name}]`), `->`, Format.blue(diff.toFixed(4)), @@ -160,7 +160,7 @@ export abstract class LoggingInterface implements ILoggingInterface { let last_mark = timer.start; for (let mark of timer.marks) { let diff = LoggingBase.nativeFunctions.diffTime(last_mark, mark.time); - this.message(LoggingTypes.Debug, [...this.#names, timer.name], [ + this.message(level, [...this.#names, timer.name], [ Format.green(`[${mark.name}]`), `->`, Format.blue(diff.toFixed(4)), @@ -169,7 +169,7 @@ export abstract class LoggingInterface implements ILoggingInterface { last_mark = mark.time; } let diff = LoggingBase.nativeFunctions.diffTime(last_mark, end_time); - this.message(LoggingTypes.Debug, [...this.#names, timer.name], [ + this.message(level, [...this.#names, timer.name], [ Format.green(`[end]`), `->`, Format.blue(diff.toFixed(4)), diff --git a/src/types.ts b/src/types.ts index 47a17b6..95b8581 100644 --- a/src/types.ts +++ b/src/types.ts @@ -241,7 +241,7 @@ export interface Adapter { export interface ILoggingTimer { mark: (label: string) => void; - end: () => number; + end: (level?: LoggingTypes) => number; } export interface ILoggingInterface { @@ -251,7 +251,7 @@ export interface ILoggingInterface { error(...message: any[]): void; time(name?: string): ILoggingTimer; - timeEnd(id: string): number; + timeEnd(id: string, level?: LoggingTypes): number; getChild(name: string): ILoggingInterface; }