egg-logger
Advanced tools
Comparing version 2.3.2 to 2.4.0
2.4.0 / 2019-03-14 | ||
================== | ||
**features** | ||
* [[`0cbbe47`](http://github.com/eggjs/egg-logger/commit/0cbbe47efb10897ac55a892bc670d3924a1ddfb5)] - feat: support contextFormatter (#51) (Haoliang Gao <<sakura9515@gmail.com>>) | ||
2.3.2 / 2019-02-28 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -22,3 +22,4 @@ interface ILoggerLevel { | ||
file: string; | ||
formatter?: any; | ||
formatter?: (meta?: object) => string; | ||
contextFormatter?: (meta?: object) => string; | ||
jsonFile?: string; | ||
@@ -164,3 +165,4 @@ outputJSON?: boolean; | ||
level?: LoggerLevel; | ||
formatter?: any; | ||
formatter?: (meta?: object) => string; | ||
contextFormatter?: (meta?: object) => string; | ||
json?: boolean; | ||
@@ -167,0 +169,0 @@ encoding?: string; |
@@ -48,2 +48,6 @@ 'use strict'; | ||
}; | ||
Object.defineProperty(meta, 'ctx', { | ||
enumerable: false, | ||
value: this.ctx, | ||
}); | ||
this._logger.log(LEVEL, arguments, meta); | ||
@@ -50,0 +54,0 @@ }; |
@@ -46,2 +46,3 @@ 'use strict'; | ||
formatter: this.options.formatter, | ||
contextFormatter: this.options.contextFormatter, | ||
flushInterval: this.options.flushInterval, | ||
@@ -67,2 +68,3 @@ eol: this.options.eol, | ||
formatter: utils.consoleFormatter, | ||
contextFormatter: this.options.contextFormatter, | ||
eol: this.options.eol, | ||
@@ -69,0 +71,0 @@ }); |
@@ -21,2 +21,3 @@ 'use strict'; | ||
* - {Function} formatter - format function | ||
* - {Function} contextFormatter - format function for context logger | ||
* - {Boolean} [json = false] - log format is json or not | ||
@@ -39,2 +40,3 @@ * - {String} [encoding = utf8] - log encodeing, see {@link https://github.com/ashtuchkin/iconv-lite#supported-encodings} | ||
formatter: null, | ||
contextFormatter: null, | ||
json: false, | ||
@@ -41,0 +43,0 @@ encoding: 'utf8', |
@@ -83,3 +83,4 @@ 'use strict'; | ||
let output; | ||
const formatter = meta.formatter || options.formatter; | ||
let formatter = meta.formatter || options.formatter; | ||
if (meta.ctx && options.contextFormatter) formatter = options.contextFormatter; | ||
@@ -86,0 +87,0 @@ if (args[0] instanceof Error) { |
{ | ||
"name": "egg-logger", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"description": "egg logger", | ||
@@ -57,4 +57,4 @@ "main": "index.js", | ||
"index.js", | ||
"index.d.ts", | ||
"lib" | ||
"lib", | ||
"index.d.ts" | ||
], | ||
@@ -61,0 +61,0 @@ "ci": { |
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
49265
1232