newrelic 8.11.0 → 8.11.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.
- package/NEWS.md +4 -0
- package/lib/instrumentation/winston.js +17 -1
- package/package.json +1 -1
package/NEWS.md
CHANGED
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
const createFormatter = require('@newrelic/winston-enricher/lib/createFormatter')
|
|
9
9
|
const API = require('../../api')
|
|
10
|
+
const Stream = require('stream')
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* winston allows you to compose a logger
|
|
14
|
+
* from an instantiated logger. Through a series
|
|
15
|
+
* of inherited classes, this logger instance is a Stream.
|
|
16
|
+
* Check what gets passed into `winston.createLogger` to avoid
|
|
17
|
+
* instrumenting an already instrumented instance of a logger.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} obj obj to check if a stream
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
function isStream(obj) {
|
|
23
|
+
return obj instanceof Stream
|
|
24
|
+
}
|
|
10
25
|
|
|
11
26
|
module.exports = function instrument(agent, winston, _, shim) {
|
|
12
27
|
const config = agent.config
|
|
@@ -32,9 +47,10 @@ module.exports = function instrument(agent, winston, _, shim) {
|
|
|
32
47
|
return function createWrappedLogger() {
|
|
33
48
|
const args = shim.argsToArray.apply(shim, arguments)
|
|
34
49
|
const opts = args[0]
|
|
35
|
-
if (!shim.isObject(opts)) {
|
|
50
|
+
if (!shim.isObject(opts) || isStream(opts)) {
|
|
36
51
|
return createLogger.apply(this, args)
|
|
37
52
|
}
|
|
53
|
+
|
|
38
54
|
if ('transports' in opts) {
|
|
39
55
|
// combine transport-level formatters with our own
|
|
40
56
|
opts.transports = opts.transports.map((transport) => {
|