UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const cls_hooked_1 = require("cls-hooked");
4const _namespace = cls_hooked_1.createNamespace('@jiaxinjiang/als');
5exports.cls = {
6 storageImplementation: 'cls-hooked',
7 get: (key) => {
8 if (_namespace.active) {
9 return _namespace.get(key);
10 }
11 return undefined;
12 },
13 set: (key, value) => {
14 if (_namespace.active) {
15 _namespace.set(key, value);
16 }
17 },
18 bindEmitter: (emitter) => {
19 _namespace.bindEmitter(emitter);
20 },
21 runWith: (callback, defaults) => {
22 _namespace.run(() => {
23 if (defaults) {
24 const objectKeys = Object.keys(defaults);
25 for (let i = 0; i < objectKeys.length; i++) {
26 _namespace.set(objectKeys[i], defaults[objectKeys[i]]);
27 }
28 }
29 callback();
30 });
31 },
32};
33exports.default = exports.cls;
34//# sourceMappingURL=logger.session.js.map
\No newline at end of file