UNPKG

e2ed

Version:

E2E testing framework over Playwright

37 lines (36 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.logAndGetLogEvent = void 0; const runId_1 = require("../../context/runId"); const config_1 = require("../config"); // eslint-disable-next-line import/no-internal-modules const registerLogEvent_1 = require("../events/registerLogEvent"); const logWithPreparedOptions_1 = require("./logWithPreparedOptions"); /** * Logs message with payload and get log event. * @internal */ const logAndGetLogEvent = (message, maybePayload, maybeLogEventType) => { const time = Date.now(); const runId = (0, runId_1.getRunId)(); const payload = typeof maybePayload === 'object' ? maybePayload : undefined; const type = typeof maybePayload === 'number' ? maybePayload : (maybeLogEventType ?? 9 /* LogEventType.Unspecified */); const { addLogsWithTags, mapLogPayloadInReport } = (0, config_1.getFullPackConfig)(); if (payload && 'logTag' in payload && !addLogsWithTags.includes(payload.logTag)) { return; } const payloadInReport = mapLogPayloadInReport(message, payload, type); const maybeLogEvent = (0, registerLogEvent_1.registerLogEvent)(runId, { children: undefined, endTime: undefined, message, payload: payloadInReport, time, type, }); (0, logWithPreparedOptions_1.logWithPreparedOptions)(message, { payload, runId, type, utcTimeInMs: time }); return maybeLogEvent; }; exports.logAndGetLogEvent = logAndGetLogEvent;