winston-meta-wrapper
Advanced tools
Comparing version 1.1.0 to 1.2.0
22
index.js
@@ -5,3 +5,3 @@ 'use strict' | ||
const formatRegExp = /%[sdj]/g | ||
var formatRegExp = /%[sdj]/g | ||
@@ -15,2 +15,3 @@ var wrapper = function (logger) { | ||
this._logger = logger | ||
this._filters = {} | ||
} | ||
@@ -29,5 +30,18 @@ | ||
} | ||
this._logger.log.apply(this._logger, args) | ||
if (this.filterApplies(args[formatArguments + 2])) { | ||
this._logger.log.apply(this._logger, args) | ||
} | ||
} | ||
WinstonMetaWrapper.prototype.filterApplies = function (metaArgs) { | ||
return _.every(this._filters, function (regex, key) { | ||
var r = new RegExp(regex) | ||
if (_.has(metaArgs, key)) { | ||
return r.test(metaArgs[key]) | ||
} else { | ||
return true | ||
} | ||
}) | ||
} | ||
WinstonMetaWrapper.prototype.error = function () { | ||
@@ -65,2 +79,6 @@ var args = Array.prototype.slice.call(arguments) | ||
WinstonMetaWrapper.prototype.setFilter = function (key, filterRegEx) { | ||
this._filters[key] = filterRegEx | ||
} | ||
WinstonMetaWrapper.prototype.addMeta = function (meta) { | ||
@@ -67,0 +85,0 @@ _.merge(this._meta, meta) |
{ | ||
"name": "winston-meta-wrapper", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Wraps Winston logger to always add a set of metadata", | ||
@@ -25,8 +25,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "^4.14.2" | ||
"lodash": "4.15.0" | ||
}, | ||
"devDependencies": { | ||
"publish": "^0.6.0", | ||
"winston": "^2.2.0" | ||
"publish": "0.6.0", | ||
"winston": "2.2.0" | ||
} | ||
} |
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
7312
116
+ Addedlodash@4.15.0(transitive)
- Removedlodash@4.17.21(transitive)
Updatedlodash@4.15.0