winston-middleware 4.2.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of winston-middleware might be problematic. Click here for more details.
- package/AUTHORS +0 -1
- package/Readme.md +1 -1
- package/index.js +7 -5
- package/package.json +9 -7
package/AUTHORS
CHANGED
package/Readme.md
CHANGED
|
@@ -84,7 +84,7 @@ Use `expressWinston.logger(options)` to create a middleware to log your HTTP req
|
|
|
84
84
|
format: [<logform.Format>], // formatting desired for log output.
|
|
85
85
|
winstonInstance: <WinstonLogger>, // a winston logger instance. If this is provided the transports and formats options are ignored.
|
|
86
86
|
level: String or function(req, res) { return String; }, // log level to use, the default is "info". Assign a function to dynamically set the level based on request and response, or a string to statically set it always at that level. statusLevels must be false for this setting to be used.
|
|
87
|
-
msg: String or function, // customize the default logging message. E.g. "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}", "HTTP {{req.method}} {{req.url}}" or function(req, res) { return `${res.statusCode} - ${req.method}
|
|
87
|
+
msg: String or function, // customize the default logging message. E.g. "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}", "HTTP {{req.method}} {{req.url}}" or function(req, res) { return `${res.statusCode} - ${req.method}` }, // Warning: while supported, returning mustache style interpolation from an options.msg function has performance and memory implications under load.
|
|
88
88
|
expressFormat: Boolean, // Use the default Express/morgan request formatting. Enabling this will override any msg if true. Will only output colors when colorize set to true
|
|
89
89
|
colorize: Boolean, // Color the text and status code, using the Express/morgan color palette (text: gray, status: default green, 3XX cyan, 4XX yellow, 5XX red).
|
|
90
90
|
meta: Boolean, // control whether you want to log the meta data about the request (default to true).
|
package/index.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
//
|
|
21
21
|
var winston = require('winston');
|
|
22
22
|
var chalk = require('chalk');
|
|
23
|
-
|
|
23
|
+
// var { getMetaData } = require('meta-templates');
|
|
24
|
+
// var { ERR_OPTIONS_META_ALL_DESCRIPTION } = require('options-msg');
|
|
24
25
|
var _ = require('lodash');
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -112,7 +113,7 @@ function filterObject(originalObj, whiteList, headerBlacklist, initialFilter) {
|
|
|
112
113
|
|
|
113
114
|
[].concat(whiteList).forEach(function (propName) {
|
|
114
115
|
var value = initialFilter(originalObj, propName);
|
|
115
|
-
if(typeof (value) !== 'undefined') {
|
|
116
|
+
if (typeof (value) !== 'undefined') {
|
|
116
117
|
_.set(obj, propName, value);
|
|
117
118
|
fieldsSet = true;
|
|
118
119
|
if (propName === 'headers') {
|
|
@@ -254,7 +255,6 @@ function levelFromStatus(options) {
|
|
|
254
255
|
// #### @options {Object} options to initialize the middleware.
|
|
255
256
|
//
|
|
256
257
|
exports.logger = function logger(options) {
|
|
257
|
-
|
|
258
258
|
ensureValidOptions(options);
|
|
259
259
|
ensureValidLoggerOptions(options);
|
|
260
260
|
|
|
@@ -447,9 +447,11 @@ function bodyToString(body, isJSON) {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
function ensureValidOptions(options) {
|
|
450
|
-
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
if (!options) throw new Error('options are required by winston-middleware');
|
|
451
453
|
if (!((options.transports && (options.transports.length > 0)) || options.winstonInstance))
|
|
452
|
-
throw new Error('transports or a winstonInstance are required by winston-middleware
|
|
454
|
+
throw new Error('transports or a winstonInstance are required by winston-middleware');
|
|
453
455
|
|
|
454
456
|
if (options.dynamicMeta && !_.isFunction(options.dynamicMeta)) {
|
|
455
457
|
throw new Error('`dynamicMeta` winston-middleware option should be a function');
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": {
|
|
3
|
-
"name": "
|
|
4
|
-
"email": "im@
|
|
5
|
-
"url": "http://
|
|
3
|
+
"name": "kasher03",
|
|
4
|
+
"email": "im@kasher.io",
|
|
5
|
+
"url": "http://kasher.io"
|
|
6
6
|
},
|
|
7
7
|
"name": "winston-middleware",
|
|
8
|
-
"description": "
|
|
8
|
+
"description": "Winston log wrappers for Express.js",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"winston",
|
|
11
11
|
"logging",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"middleware",
|
|
17
17
|
"colors"
|
|
18
18
|
],
|
|
19
|
-
"version": "4.
|
|
19
|
+
"version": "4.3.1",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
22
|
"url": "https://github.com/bithavoc/winston-middleware.git"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "http://github.com/bithavoc/winston-middleware/issues",
|
|
26
|
-
"email": "im@
|
|
26
|
+
"email": "im@kasher.io"
|
|
27
27
|
},
|
|
28
28
|
"main": "index.js",
|
|
29
29
|
"scripts": {
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"chalk": "^2.4.2",
|
|
35
|
-
"lodash": "^4.17.21"
|
|
35
|
+
"lodash": "^4.17.21",
|
|
36
|
+
"meta-templates": "^1.0.0",
|
|
37
|
+
"options-msg": "^1.0.1"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@types/express": "^4.17.1",
|