@freemework/common
Version:
Common library of the Freemework Project.
49 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FLoggerLabelsExecutionElement = exports.FLoggerLabelsExecutionContext = void 0;
const f_execution_context_js_1 = require("../execution_context/f_execution_context.js");
class FLoggerLabelsExecutionContext extends f_execution_context_js_1.FExecutionContextBase {
_loggerLabelValues;
static of(executionContext) {
const loggerCtx = f_execution_context_js_1.FExecutionContext.findExecutionContext(executionContext, FLoggerLabelsExecutionContext);
if (loggerCtx === null) {
return null;
}
const chain = [loggerCtx];
const prevExecutionContext = loggerCtx.prevContext;
if (prevExecutionContext != null) {
chain.push(...f_execution_context_js_1.FExecutionContext
.listExecutionContexts(prevExecutionContext, FLoggerLabelsExecutionContext));
}
return new FLoggerLabelsExecutionElement(loggerCtx, chain);
}
// TODO: make true-readonly set
get loggerLabelValues() { return this._loggerLabelValues; }
constructor(prevContext, ...loggerLabelValues) {
super(prevContext);
this._loggerLabelValues = Object.freeze([...loggerLabelValues]);
}
}
exports.FLoggerLabelsExecutionContext = FLoggerLabelsExecutionContext;
class FLoggerLabelsExecutionElement extends f_execution_context_js_1.FExecutionElement {
chain;
constructor(owner, chain) {
super(owner);
this.chain = chain;
}
get loggerLabelValues() {
// using reduceRight to take priority for first property in chain.
const dict = this.chain.reduceRight((p, c) => {
c.loggerLabelValues.forEach((lv) => {
if (!p.has(lv.label)) {
p.set(lv.label, lv);
}
});
return p;
}, new Map);
// TODO: make true-readonly set
return [...dict.values()];
}
}
exports.FLoggerLabelsExecutionElement = FLoggerLabelsExecutionElement;
//# sourceMappingURL=f_logger_labels_execution_context.js.map