@highoutput/logger
Advanced tools
Comparing version 0.3.0 to 0.4.0
declare type Argument = number | string | Error | object; | ||
declare class Logger { | ||
private loggers; | ||
private tags; | ||
@@ -5,0 +4,0 @@ constructor(tags: string | string[]); |
@@ -7,2 +7,6 @@ "use strict"; | ||
const debug_1 = __importDefault(require("debug")); | ||
const lru_cache_1 = __importDefault(require("lru-cache")); | ||
const loggers = new lru_cache_1.default({ | ||
max: 32768, | ||
}); | ||
class Logger { | ||
@@ -16,7 +20,6 @@ constructor(tags) { | ||
} | ||
this.loggers = {}; | ||
} | ||
tag(tags) { | ||
return new Logger([ | ||
...this.tags, | ||
...this.tags.splice(0), | ||
...(typeof tags === 'string' ? [tags] : tags), | ||
@@ -28,4 +31,6 @@ ]); | ||
const scope = `${level}${tags ? `:${tags}` : ''}`; | ||
const logger = this.loggers[scope] ? this.loggers[scope] : debug_1.default(scope); | ||
this.loggers[scope] = logger; | ||
const logger = loggers.get(scope) || debug_1.default(scope); | ||
if (!loggers.get(scope)) { | ||
loggers.set(scope, logger); | ||
} | ||
args | ||
@@ -32,0 +37,0 @@ .map((item) => { |
{ | ||
"name": "@highoutput/logger", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"debug": "^3.1.0" | ||
"debug": "^3.1.0", | ||
"lru-cache": "^6.0.0" | ||
}, | ||
@@ -18,2 +19,3 @@ "scripts": { | ||
"@types/debug": "^4.1.5", | ||
"@types/lru-cache": "^5.1.0", | ||
"@types/mocha": "^5.2.7", | ||
@@ -29,3 +31,3 @@ "@types/node": "^13.13.21", | ||
}, | ||
"gitHead": "bf6c295a2cf886808dfc750a72cd23ea9c195b3a" | ||
"gitHead": "63606137c47f151e4170910bb3265c50121f1ad1" | ||
} |
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
8796
91
2
8
+ Addedlru-cache@^6.0.0
+ Addedlru-cache@6.0.0(transitive)
+ Addedyallist@4.0.0(transitive)