winston-middleware 1.3.1 → 1.4.0

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/Readme.md CHANGED
@@ -118,6 +118,7 @@ The logger needs to be added AFTER the express router(`app.router)`) and BEFORE
118
118
  metaField: String, // if defined, the meta data will be added in this field instead of the meta root object.
119
119
  requestFilter: function (req, propName) { return req[propName]; } // A function to filter/return request values, defaults to returning all values allowed by whitelist. If the function returns undefined, the key/value will not be included in the meta.
120
120
  requestWhitelist: [String] // Array of request properties to log. Overrides global requestWhitelist for this instance
121
+ level: String // custom log level for errors (default is 'error')
121
122
  ```
122
123
 
123
124
  To use winston's existing transports, set `transports` to the values (as in key-value) of the `winston.default.transports` object. This may be done, for example, by using underscorejs: `transports: _.values(winston.default.transports)`.
package/index.js CHANGED
@@ -121,6 +121,7 @@ exports.errorLogger = function errorLogger(options) {
121
121
  options.msg = options.msg || 'middlewareError';
122
122
  options.baseMeta = options.baseMeta || {};
123
123
  options.metaField = options.metaField || null;
124
+ options.level = options.level || 'error';
124
125
 
125
126
  // Using mustache style templating
126
127
  var template = _.template(options.msg, {
@@ -142,7 +143,7 @@ exports.errorLogger = function errorLogger(options) {
142
143
  exceptionMeta = _.extend(exceptionMeta, options.baseMeta);
143
144
 
144
145
  // This is fire and forget, we don't want logging to hold up the request so don't wait for the callback
145
- options.winstonInstance.log('error', template({err: err, req: req, res: res}), exceptionMeta);
146
+ options.winstonInstance.log(options.level, template({err: err, req: req, res: res}), exceptionMeta);
146
147
 
147
148
  next(err);
148
149
  };
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "middleware",
18
18
  "colors"
19
19
  ],
20
- "version": "1.3.1",
20
+ "version": "1.4.0",
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "https://github.com/bithavoc/winston-middleware.git"
package/test/test.js CHANGED
@@ -189,12 +189,19 @@ describe('winston-middleware', function () {
189
189
  });
190
190
  });
191
191
 
192
- it('should find an error level of "error"', function () {
192
+ it('should find the default level of "error"', function () {
193
193
  return errorLoggerTestHelper().then(function (result) {
194
194
  result.log.level.should.eql('error');
195
195
  });
196
196
  });
197
197
 
198
+ it('should find a custom level of "warn"', function () {
199
+ var testHelperOptions = {loggerOptions: {level:'warn'}};
200
+ return errorLoggerTestHelper(testHelperOptions).then(function (result) {
201
+ result.log.level.should.eql('warn');
202
+ });
203
+ });
204
+
198
205
  it('should find a message of "middlewareError"', function () {
199
206
  return errorLoggerTestHelper().then(function (result) {
200
207
  result.log.msg.should.eql('middlewareError');