Comparing version 3.7.1 to 3.7.2
@@ -41,4 +41,3 @@ /** | ||
LEVEL = _require2.LEVEL, | ||
SPLAT = _require2.SPLAT, | ||
MESSAGE = _require2.MESSAGE; | ||
SPLAT = _require2.SPLAT; | ||
@@ -59,4 +58,2 @@ var isStream = require('is-stream'); | ||
var config = require('./config'); | ||
var jsonStringify = require('safe-stable-stringify'); | ||
/** | ||
@@ -103,8 +100,21 @@ * Captures the number of format (i.e. %s strings) in a given string. | ||
key: "child", | ||
value: function child(childMetadata) { | ||
value: function child(defaultRequestMetadata) { | ||
var logger = this; | ||
var clonedParentMetadata = JSON.parse(jsonStringify(this.defaultMeta)); | ||
return Object.create(logger, { | ||
defaultMeta: { | ||
value: Object.assign({}, clonedParentMetadata, childMetadata) | ||
write: { | ||
value: function value(info) { | ||
var infoClone = Object.assign({}, defaultRequestMetadata, info); // Object.assign doesn't copy inherited Error | ||
// properties so we have to do that explicitly | ||
// | ||
// Remark (indexzero): we should remove this | ||
// since the errors format will handle this case. | ||
// | ||
if (info instanceof Error) { | ||
infoClone.stack = info.stack; | ||
infoClone.message = info.message; | ||
} | ||
logger.write(infoClone); | ||
} | ||
} | ||
@@ -345,6 +355,2 @@ }); | ||
info[LEVEL] = info.level; | ||
} | ||
if (!info[MESSAGE]) { | ||
info[MESSAGE] = info.message; | ||
} // Remark: really not sure what to do here, but this has been reported as | ||
@@ -733,5 +739,3 @@ // very confusing by pre winston@2.0.0 users as quite confusing when using | ||
if (this.defaultMeta) { | ||
// The msg must be cloned as it is being mutated, but any metadata provided with the msg takes precedence over default | ||
var msgClone = JSON.parse(jsonStringify(msg)); | ||
Object.assign(msg, this.defaultMeta, msgClone); | ||
Object.assign(msg, this.defaultMeta); | ||
} | ||
@@ -738,0 +742,0 @@ } |
@@ -33,4 +33,2 @@ /** | ||
// TODO there is no restriction on what the Profiler considers a Logger. As such there is no guarantees it adheres | ||
// to the proper interface. This needs to hardened. | ||
if (!logger) { | ||
@@ -46,4 +44,3 @@ throw new Error('Logger is required for profiling.'); | ||
* with the duration since creation. | ||
* @returns {boolean} - `false` if the logger stream wishes for the calling code to wait for the 'drain' event to be | ||
* emitted before continuing to write additional data; otherwise `true` | ||
* @returns {mixed} - TODO: add return description. | ||
* @private | ||
@@ -69,3 +66,2 @@ */ | ||
info.durationMs = Date.now() - this.start; | ||
if (this.logger._addDefaultMeta) this.logger._addDefaultMeta(info); | ||
return this.logger.write(info); | ||
@@ -72,0 +68,0 @@ } |
@@ -12,3 +12,3 @@ /** | ||
const asyncForEach = require('async/forEach'); | ||
const { LEVEL, SPLAT, MESSAGE } = require('triple-beam'); | ||
const { LEVEL, SPLAT } = require('triple-beam'); | ||
const isStream = require('is-stream'); | ||
@@ -21,3 +21,2 @@ const ExceptionHandler = require('./exception-handler'); | ||
const config = require('./config'); | ||
const jsonStringify = require('safe-stable-stringify'); | ||
@@ -48,8 +47,26 @@ /** | ||
child(childMetadata) { | ||
child(defaultRequestMetadata) { | ||
const logger = this; | ||
const clonedParentMetadata = JSON.parse(jsonStringify(this.defaultMeta)); | ||
return Object.create(logger, { | ||
defaultMeta: { | ||
value: Object.assign({}, clonedParentMetadata, childMetadata) | ||
write: { | ||
value: function (info) { | ||
const infoClone = Object.assign( | ||
{}, | ||
defaultRequestMetadata, | ||
info | ||
); | ||
// Object.assign doesn't copy inherited Error | ||
// properties so we have to do that explicitly | ||
// | ||
// Remark (indexzero): we should remove this | ||
// since the errors format will handle this case. | ||
// | ||
if (info instanceof Error) { | ||
infoClone.stack = info.stack; | ||
infoClone.message = info.message; | ||
} | ||
logger.write(infoClone); | ||
} | ||
} | ||
@@ -277,6 +294,2 @@ }); | ||
if (!info[MESSAGE]) { | ||
info[MESSAGE] = info.message; | ||
} | ||
// Remark: really not sure what to do here, but this has been reported as | ||
@@ -641,5 +654,3 @@ // very confusing by pre winston@2.0.0 users as quite confusing when using | ||
if (this.defaultMeta) { | ||
// The msg must be cloned as it is being mutated, but any metadata provided with the msg takes precedence over default | ||
const msgClone = JSON.parse(jsonStringify(msg)); | ||
Object.assign(msg, this.defaultMeta, msgClone); | ||
Object.assign(msg, this.defaultMeta); | ||
} | ||
@@ -646,0 +657,0 @@ } |
@@ -24,4 +24,2 @@ /** | ||
constructor(logger) { | ||
// TODO there is no restriction on what the Profiler considers a Logger. As such there is no guarantees it adheres | ||
// to the proper interface. This needs to hardened. | ||
if (!logger) { | ||
@@ -38,4 +36,3 @@ throw new Error('Logger is required for profiling.'); | ||
* with the duration since creation. | ||
* @returns {boolean} - `false` if the logger stream wishes for the calling code to wait for the 'drain' event to be | ||
* emitted before continuing to write additional data; otherwise `true` | ||
* @returns {mixed} - TODO: add return description. | ||
* @private | ||
@@ -53,5 +50,5 @@ */ | ||
info.durationMs = (Date.now()) - this.start; | ||
if (this.logger._addDefaultMeta) this.logger._addDefaultMeta(info); | ||
return this.logger.write(info); | ||
} | ||
}; |
{ | ||
"name": "winston", | ||
"description": "A logger for just about everything.", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"author": "Charlie Robbins <charlie.robbins@gmail.com>", | ||
@@ -63,3 +63,2 @@ "maintainers": [ | ||
"lint": "eslint lib/*.js lib/winston/*.js lib/winston/**/*.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist", | ||
"lint:fix": "npm run lint -- --fix", | ||
"test": "mocha", | ||
@@ -66,0 +65,0 @@ "test:coverage": "nyc npm run test:unit", |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
6104
0
264817
88
1
2
9