UNPKG

logmessage-cls-hooked

Version:

A LogRoot Method Decorator that uses cls-hooked to handle and propagate log message details between different methods deeper in the callstack, removing the need to propagate a paremeter just for logging purposes

19 lines (18 loc) 787 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._setPropKeyHistory = exports._getSessionOrFail = void 0; var cls_hooked_1 = require("cls-hooked"); var constants_1 = require("./constants"); var _getSessionOrFail = function () { var session = (0, cls_hooked_1.getNamespace)(constants_1.NAMESPACE_KEY); if (!session) throw new Error('@LOG_ROOT Session is not created'); return session; }; exports._getSessionOrFail = _getSessionOrFail; var _setPropKeyHistory = function (session, propName) { var _a; var alreadSetProps = (_a = session.get(constants_1.PROP_KEY)) !== null && _a !== void 0 ? _a : []; session.set(constants_1.PROP_KEY, alreadSetProps.concat([propName])); }; exports._setPropKeyHistory = _setPropKeyHistory;