Comparing version 2.15.1 to 2.15.2
@@ -63,2 +63,29 @@ "use strict"; | ||
const getFirstParentDomainContext = () => { | ||
if (!domain) { | ||
return {}; | ||
} | ||
let currentDomain = process.domain; // $FlowFixMe | ||
if (currentDomain && currentDomain.roarr && currentDomain.roarr.context) { | ||
return currentDomain.roarr.context; | ||
} // $FlowFixMe | ||
if (!currentDomain || !currentDomain.parentDomain) { | ||
return {}; | ||
} | ||
while (currentDomain && currentDomain.parentDomain) { | ||
currentDomain = currentDomain.parentDomain; | ||
if (currentDomain.roarr && currentDomain.roarr.context) { | ||
return currentDomain.roarr.context; | ||
} | ||
} | ||
return {}; | ||
}; | ||
const createLogger = (onMessage, parentContext) => { | ||
@@ -73,3 +100,3 @@ // eslint-disable-next-line id-length, unicorn/prevent-abbreviations | ||
if (typeof a === 'string') { | ||
context = _objectSpread({}, domain && process.domain && process.domain.roarr && process.domain.roarr.context, {}, parentContext || {}); | ||
context = _objectSpread({}, getFirstParentDomainContext(), {}, parentContext || {}); | ||
message = (0, _sprintfJs.sprintf)(a, b, c, d, e, f, g, h, i, k); | ||
@@ -81,3 +108,3 @@ } else { | ||
context = JSON.parse((0, _jsonStringifySafe.default)(_objectSpread({}, domain && process.domain && process.domain.roarr && process.domain.roarr.context, {}, parentContext || {}, {}, a))); | ||
context = JSON.parse((0, _jsonStringifySafe.default)(_objectSpread({}, getFirstParentDomainContext(), {}, parentContext || {}, {}, a))); | ||
message = (0, _sprintfJs.sprintf)(b, c, d, e, f, g, h, i, k); | ||
@@ -106,7 +133,7 @@ } | ||
return createLogger(onMessage, _objectSpread({}, domain && process.domain && process.domain.roarr && process.domain.roarr.context, {}, parentContext, {}, context)); | ||
return createLogger(onMessage, _objectSpread({}, getFirstParentDomainContext(), {}, parentContext, {}, context)); | ||
}; | ||
log.getContext = () => { | ||
return _objectSpread({}, domain && process.domain && process.domain.roarr && process.domain.roarr.context, {}, parentContext || {}); | ||
return _objectSpread({}, getFirstParentDomainContext(), {}, parentContext || {}); | ||
}; | ||
@@ -123,3 +150,3 @@ | ||
adoptedDomain.roarr = { | ||
context: _objectSpread({}, getParentDomainContext() || {}, {}, context) | ||
context: _objectSpread({}, getParentDomainContext(), {}, context) | ||
}; | ||
@@ -126,0 +153,0 @@ return routine(); |
@@ -91,3 +91,3 @@ { | ||
}, | ||
"version": "2.15.1" | ||
"version": "2.15.2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64242
287