@zodash/logger
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.2.10](https://github.com/zcorky/zodash/compare/@zodash/logger@0.2.9...@zodash/logger@0.2.10) (2020-11-30) | ||
**Note:** Version bump only for package @zodash/logger | ||
## [0.2.9](https://github.com/zcorky/zodash/compare/@zodash/logger@0.2.8...@zodash/logger@0.2.9) (2020-11-27) | ||
@@ -8,0 +16,0 @@ |
@@ -36,6 +36,9 @@ import { Onion, Context, Middleware } from '@zodash/onion'; | ||
private readonly options?; | ||
static _disableFn: any; | ||
static create(name: string, options?: Options): Logger; | ||
static setDisable(fn: () => boolean): void; | ||
constructor(name: string, options?: Options); | ||
private useDefaulEngine; | ||
private useDateTime; | ||
private useDefaulEngine; | ||
private useDisable; | ||
handle(): Middleware<Context<Input, any, any>>; | ||
@@ -42,0 +45,0 @@ log(message: string, ...args: any[]): void; |
@@ -30,4 +30,4 @@ "use strict"; | ||
function formatMessage(name, date, message, level) { | ||
const prefix = format_1.format('[{datetime} - {name}] - [{level}] -', { | ||
name, | ||
const prefix = format_1.format('[{name}] {datetime} - {level} -', { | ||
name: name || 'COMMON', | ||
datetime: date.format('YYYY-MM-DD HH:mm:ss'), | ||
@@ -56,2 +56,3 @@ level: level.toUpperCase() || 'LOG', | ||
this.options = options || {}; | ||
this.use(this.useDisable()); | ||
this.use(this.useDefaulEngine()); | ||
@@ -63,2 +64,11 @@ this.use(this.useDateTime()); | ||
} | ||
static setDisable(fn) { | ||
Logger._disableFn = fn; | ||
} | ||
useDefaulEngine() { | ||
return (ctx, next) => __awaiter(this, void 0, void 0, function* () { | ||
ctx.input.engine = console; | ||
yield next(); | ||
}); | ||
} | ||
useDateTime() { | ||
@@ -70,5 +80,8 @@ return (ctx, next) => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
useDefaulEngine() { | ||
useDisable() { | ||
return (ctx, next) => __awaiter(this, void 0, void 0, function* () { | ||
ctx.input.engine = console; | ||
const enable = !Logger._disableFn ? true : Logger._disableFn(); | ||
if (!enable) { | ||
return; | ||
} | ||
yield next(); | ||
@@ -148,2 +161,3 @@ }); | ||
exports.Logger = Logger; | ||
Logger._disableFn = null; | ||
function getLogger(name, options) { | ||
@@ -150,0 +164,0 @@ return Logger.create(name, options); |
{ | ||
"name": "@zodash/logger", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "simple logger model", | ||
@@ -72,3 +72,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "906db21b1e19d463277914b235a0ad32af77c79b" | ||
"gitHead": "ed66fc04e51afdf9674af266c1b7fa99e85a635e" | ||
} |
Sorry, the diff of this file is not supported yet
21960
237