@xylabs/logger
Advanced tools
Comparing version 2.13.22 to 2.13.23
// src/Logger.ts | ||
import { handleError } from "@xylabs/error"; | ||
var LogLevel = /* @__PURE__ */ ((LogLevel2) => { | ||
LogLevel2[LogLevel2["error"] = 1] = "error"; | ||
LogLevel2[LogLevel2["warn"] = 2] = "warn"; | ||
LogLevel2[LogLevel2["info"] = 3] = "info"; | ||
LogLevel2[LogLevel2["debug"] = 4] = "debug"; | ||
LogLevel2[LogLevel2["log"] = 5] = "log"; | ||
return LogLevel2; | ||
})(LogLevel || {}); | ||
var NoOpLogFunction = (_message) => void 0; | ||
var ConsoleLogger = class { | ||
constructor(level = 2 /* warn */) { | ||
this.level = level; | ||
} | ||
get debug() { | ||
return this.level <= 4 /* debug */ ? console.debug : NoOpLogFunction; | ||
} | ||
get error() { | ||
return this.level <= 1 /* error */ ? console.error : NoOpLogFunction; | ||
} | ||
get info() { | ||
return this.level <= 3 /* info */ ? console.info : NoOpLogFunction; | ||
} | ||
get log() { | ||
return this.level <= 5 /* log */ ? console.log : NoOpLogFunction; | ||
} | ||
get warn() { | ||
return this.level <= 2 /* warn */ ? console.warn : NoOpLogFunction; | ||
} | ||
}; | ||
var getFunctionName = (depth = 2) => { | ||
@@ -54,5 +83,8 @@ try { | ||
export { | ||
ConsoleLogger, | ||
IdLogger, | ||
LogLevel, | ||
NoOpLogFunction, | ||
getFunctionName | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -13,3 +13,35 @@ export type LogFunction = (message?: unknown) => void; | ||
} | ||
export declare enum LogLevel { | ||
error = 1, | ||
warn = 2, | ||
info = 3, | ||
debug = 4, | ||
log = 5 | ||
} | ||
export declare const NoOpLogFunction: (_message?: unknown) => undefined; | ||
export declare class ConsoleLogger implements Logger { | ||
readonly level: LogLevel; | ||
constructor(level?: LogLevel); | ||
get debug(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get error(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get info(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get log(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get warn(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
} | ||
export declare const getFunctionName: (depth?: number) => string; | ||
//# sourceMappingURL=Logger.d.ts.map |
// src/Logger.ts | ||
import { handleError } from "@xylabs/error"; | ||
var LogLevel = /* @__PURE__ */ ((LogLevel2) => { | ||
LogLevel2[LogLevel2["error"] = 1] = "error"; | ||
LogLevel2[LogLevel2["warn"] = 2] = "warn"; | ||
LogLevel2[LogLevel2["info"] = 3] = "info"; | ||
LogLevel2[LogLevel2["debug"] = 4] = "debug"; | ||
LogLevel2[LogLevel2["log"] = 5] = "log"; | ||
return LogLevel2; | ||
})(LogLevel || {}); | ||
var NoOpLogFunction = (_message) => void 0; | ||
var ConsoleLogger = class { | ||
constructor(level = 2 /* warn */) { | ||
this.level = level; | ||
} | ||
get debug() { | ||
return this.level <= 4 /* debug */ ? console.debug : NoOpLogFunction; | ||
} | ||
get error() { | ||
return this.level <= 1 /* error */ ? console.error : NoOpLogFunction; | ||
} | ||
get info() { | ||
return this.level <= 3 /* info */ ? console.info : NoOpLogFunction; | ||
} | ||
get log() { | ||
return this.level <= 5 /* log */ ? console.log : NoOpLogFunction; | ||
} | ||
get warn() { | ||
return this.level <= 2 /* warn */ ? console.warn : NoOpLogFunction; | ||
} | ||
}; | ||
var getFunctionName = (depth = 2) => { | ||
@@ -60,5 +89,8 @@ try { | ||
export { | ||
ConsoleLogger, | ||
IdLogger, | ||
LogLevel, | ||
NoOpLogFunction, | ||
getFunctionName | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -13,3 +13,35 @@ export type LogFunction = (message?: unknown) => void; | ||
} | ||
export declare enum LogLevel { | ||
error = 1, | ||
warn = 2, | ||
info = 3, | ||
debug = 4, | ||
log = 5 | ||
} | ||
export declare const NoOpLogFunction: (_message?: unknown) => undefined; | ||
export declare class ConsoleLogger implements Logger { | ||
readonly level: LogLevel; | ||
constructor(level?: LogLevel); | ||
get debug(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get error(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get info(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get log(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
get warn(): { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
} | ||
export declare const getFunctionName: (depth?: number) => string; | ||
//# sourceMappingURL=Logger.d.ts.map |
@@ -14,3 +14,3 @@ { | ||
"dependencies": { | ||
"@xylabs/error": "~2.13.22" | ||
"@xylabs/error": "~2.13.23" | ||
}, | ||
@@ -72,4 +72,4 @@ "devDependencies": { | ||
"sideEffects": false, | ||
"version": "2.13.22", | ||
"version": "2.13.23", | ||
"type": "module" | ||
} |
@@ -17,2 +17,35 @@ import { handleError } from '@xylabs/error' | ||
export enum LogLevel { | ||
error = 1, | ||
warn = 2, | ||
info = 3, | ||
debug = 4, | ||
log = 5, | ||
} | ||
export const NoOpLogFunction = (_message?: unknown) => void {} | ||
export class ConsoleLogger implements Logger { | ||
constructor(readonly level: LogLevel = LogLevel.warn) {} | ||
get debug() { | ||
return this.level <= LogLevel.debug ? console.debug : NoOpLogFunction | ||
} | ||
get error() { | ||
return this.level <= LogLevel.error ? console.error : NoOpLogFunction | ||
} | ||
get info() { | ||
return this.level <= LogLevel.info ? console.info : NoOpLogFunction | ||
} | ||
get log() { | ||
return this.level <= LogLevel.log ? console.log : NoOpLogFunction | ||
} | ||
get warn() { | ||
return this.level <= LogLevel.warn ? console.warn : NoOpLogFunction | ||
} | ||
} | ||
export const getFunctionName = (depth = 2) => { | ||
@@ -19,0 +52,0 @@ try { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65979
631
Updated@xylabs/error@~2.13.23