23 lines
926 B
JavaScript
23 lines
926 B
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const logger_1 = __importDefault(require("./logger"));
|
||
|
const texts_1 = require("./texts");
|
||
|
function assignReporterMethods(reporterObject, reporterMethods, isLogEnabled) {
|
||
|
for (const methodName of Object.keys(reporterMethods)) {
|
||
|
reporterObject[methodName] = async function (...args) {
|
||
|
if (isLogEnabled)
|
||
|
logger_1.default.log(`${methodName}: ${JSON.stringify(args)}`);
|
||
|
try {
|
||
|
await reporterMethods[methodName].apply(this, args);
|
||
|
}
|
||
|
catch (e) {
|
||
|
logger_1.default.error(texts_1.createReporterMethodName(methodName, e && e.toString()));
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
exports.default = assignReporterMethods;
|