@contrail/telemetry 1.0.2-alpha-plat927-3 → 1.0.2
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/CHANGELOG.md +11 -0
- package/lib/logger/index.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.2] - 2026-03-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Shared logger for libraries** — Any package can now `import { logger } from '@contrail/telemetry'` and get structured logging with request context, automatically enhanced when running inside a host service.
|
|
15
|
+
- **Browser safety** — Safe to import in browser environments (no `process is not defined` errors).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Logger singleton now survives npm module duplication — no `overrides` needed for `@contrail/telemetry`.
|
|
20
|
+
|
|
10
21
|
## [1.0.0] - (initial changelog entry)
|
|
11
22
|
|
|
12
23
|
- Initial changelog. Prior releases did not include a changelog.
|
package/lib/logger/index.js
CHANGED
|
@@ -8,11 +8,12 @@ exports.logger = void 0;
|
|
|
8
8
|
exports.setLogger = setLogger;
|
|
9
9
|
const pino_1 = __importDefault(require("pino"));
|
|
10
10
|
const LOGGER_KEY = Symbol.for('@contrail/telemetry:logger');
|
|
11
|
+
const globalStore = globalThis;
|
|
11
12
|
const level = typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.LOG_LEVEL) ? process.env.LOG_LEVEL : 'debug';
|
|
12
13
|
const defaultLogger = (0, pino_1.default)({ level });
|
|
13
14
|
function getLogger() {
|
|
14
15
|
var _a;
|
|
15
|
-
return (_a =
|
|
16
|
+
return (_a = globalStore[LOGGER_KEY]) !== null && _a !== void 0 ? _a : defaultLogger;
|
|
16
17
|
}
|
|
17
18
|
exports.logger = new Proxy({}, {
|
|
18
19
|
get(_, prop) {
|
|
@@ -25,5 +26,5 @@ exports.logger = new Proxy({}, {
|
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
function setLogger(replacement) {
|
|
28
|
-
|
|
29
|
+
globalStore[LOGGER_KEY] = replacement;
|
|
29
30
|
}
|