@contrail/telemetry 2.0.5 → 2.0.6-alpha.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.
- package/lib/logger/stdout-writer.js +10 -10
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stdoutWriter = void 0;
|
|
4
|
-
// Capture
|
|
4
|
+
// Capture console.log so we can use it from the pino stdout stream.
|
|
5
5
|
// Lambda treats each console.log() call as a single CloudWatch log event (even with
|
|
6
|
-
// embedded newlines), unlike process.stdout.write() which splits on \n.
|
|
7
|
-
// original lets us pretty-print objects without them scattering across log events.
|
|
6
|
+
// embedded newlines), unlike process.stdout.write() which splits on \n.
|
|
8
7
|
//
|
|
9
|
-
// Guard:
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// Guard: app-framework's hijackConsole() replaces console.log with overridenLog,
|
|
9
|
+
// which routes back into pino — using it here would create an infinite loop.
|
|
10
|
+
// We detect that specific replacement by name. Any other replacement (e.g. the
|
|
11
|
+
// OTel Lambda layer's console patch) is safe to use.
|
|
12
12
|
const _capturedConsoleLog = console.log;
|
|
13
|
-
const
|
|
13
|
+
const isAppFrameworkHijack = _capturedConsoleLog.name === 'overridenLog';
|
|
14
14
|
// Wrapped in an object so tests can jest.spyOn(stdoutWriter, 'log') regardless
|
|
15
15
|
// of Jest's console patching strategy (BufferedConsole vs CustomConsole).
|
|
16
16
|
exports.stdoutWriter = {
|
|
17
|
-
log:
|
|
18
|
-
?
|
|
19
|
-
:
|
|
17
|
+
log: isAppFrameworkHijack
|
|
18
|
+
? (...args) => process.stdout.write(args.map(String).join(' ') + '\n')
|
|
19
|
+
: _capturedConsoleLog,
|
|
20
20
|
};
|