@zodash/logger
Advanced tools
Comparing version 1.0.3 to 1.0.6
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.0.6](https://github.com/zcorky/zodash/compare/@zodash/logger@1.0.3...@zodash/logger@1.0.6) (2022-12-06) | ||
**Note:** Version bump only for package @zodash/logger | ||
## [1.0.3](https://github.com/zcorky/zodash/compare/@zodash/logger@1.0.1...@zodash/logger@1.0.3) (2022-08-25) | ||
@@ -8,0 +16,0 @@ |
@@ -46,2 +46,3 @@ import { Onion, Context, Middleware } from '@zodash/onion'; | ||
private logFiles; | ||
private level; | ||
constructor(name: string, options?: Options); | ||
@@ -60,2 +61,3 @@ private useDefaulEngine; | ||
setLogDir(logDir: string): void; | ||
setLogLevel(level: 'info' | 'debug' | 'warn' | 'error'): void; | ||
getQueue(): Promise<Input[]>; | ||
@@ -62,0 +64,0 @@ } |
@@ -18,2 +18,11 @@ "use strict"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
const LogLevelWeight = { | ||
debug: 0, | ||
info: 1, | ||
warn: 2, | ||
error: 3, | ||
fatal: 4, | ||
// | ||
log: 1, | ||
}; | ||
// we support pattern | ||
@@ -55,2 +64,3 @@ // %s | ||
this.logFiles = {}; | ||
this.level = 'info'; | ||
this.getLogFile = async function (level) { | ||
@@ -138,2 +148,8 @@ // eslint-disable-next-line | ||
} | ||
// info(1) > debug(0) => hide | ||
// error(3) > info(1) => hide | ||
// info(1) < error(3) => show | ||
if (LogLevelWeight[this.level] > LogLevelWeight[input.level]) { | ||
return; | ||
} | ||
const isUseDevConsole = Array.isArray(message); | ||
@@ -246,2 +262,7 @@ if (!isUseDevConsole) { | ||
} | ||
setLogLevel(level) { | ||
if (level) { | ||
this.level = level.toLowerCase(); | ||
} | ||
} | ||
async getQueue() { | ||
@@ -248,0 +269,0 @@ return queue; |
{ | ||
"name": "@zodash/logger", | ||
"version": "1.0.3", | ||
"version": "1.0.6", | ||
"description": "simple logger model", | ||
@@ -44,4 +44,4 @@ "keywords": [ | ||
"global": { | ||
"branches": 60, | ||
"functions": 70, | ||
"branches": 50, | ||
"functions": 60, | ||
"lines": 60, | ||
@@ -74,3 +74,3 @@ "statements": 0 | ||
}, | ||
"gitHead": "904b321385e76218f7d1a49639db17a4754b66cf" | ||
"gitHead": "b8403633597410e5a87f85b50a6d3b88fe3357eb" | ||
} |
27942
379