@contrail/telemetry 1.0.2 → 1.1.0-alpha-frontend-logging-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 +2 -8
- package/lib/logger/index.js +6 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,16 +7,10 @@ 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
10
|
### Changed
|
|
18
11
|
|
|
19
|
-
-
|
|
12
|
+
- **Browser-safe**: `@contrail/telemetry` can now be imported in browser environments. Pino v10's built-in browser build provides the same `pino.Logger` interface backed by native `console.*` methods.
|
|
13
|
+
- Libraries that previously had no logging can now `import { logger } from '@contrail/telemetry'` regardless of runtime environment.
|
|
20
14
|
|
|
21
15
|
## [1.0.0] - (initial changelog entry)
|
|
22
16
|
|
package/lib/logger/index.js
CHANGED
|
@@ -7,24 +7,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.logger = void 0;
|
|
8
8
|
exports.setLogger = setLogger;
|
|
9
9
|
const pino_1 = __importDefault(require("pino"));
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function getLogger() {
|
|
15
|
-
var _a;
|
|
16
|
-
return (_a = globalStore[LOGGER_KEY]) !== null && _a !== void 0 ? _a : defaultLogger;
|
|
17
|
-
}
|
|
10
|
+
const level = typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.LOG_LEVEL)
|
|
11
|
+
? process.env.LOG_LEVEL
|
|
12
|
+
: 'debug';
|
|
13
|
+
let _logger = (0, pino_1.default)({ level });
|
|
18
14
|
exports.logger = new Proxy({}, {
|
|
19
15
|
get(_, prop) {
|
|
20
|
-
|
|
21
|
-
const value = Reflect.get(target, prop, target);
|
|
22
|
-
if (typeof value === 'function') {
|
|
23
|
-
return value.bind(target);
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
16
|
+
return Reflect.get(_logger, prop, _logger);
|
|
26
17
|
},
|
|
27
18
|
});
|
|
28
19
|
function setLogger(replacement) {
|
|
29
|
-
|
|
20
|
+
_logger = replacement;
|
|
30
21
|
}
|