59 lines
2.5 KiB
JavaScript
59 lines
2.5 KiB
JavaScript
// Metro module 951 (f952).
|
|
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from "./Module839";
|
|
import * as _consoleSandbox from "./consoleSandbox";
|
|
import { debug } from "./consoleSandbox";
|
|
import { DEBUG_BUILD } from "./Module823";
|
|
import { addConsoleInstrumentationHandler } from "./instrumentConsole";
|
|
import { getClient } from "./Module848";
|
|
import { hasConsoleSubstitutions, createConsoleTemplateAttributes, formatConsoleArgs } from "./Module952";
|
|
import { _INTERNAL_captureLog } from "./Module880";
|
|
import { defineIntegration } from "./setupIntegration";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
const r12 = {};
|
|
r12[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.log.console";
|
|
const attributes = r12;
|
|
export const consoleLoggingIntegration = defineIntegration(function(r1 = {}) {
|
|
const CONSOLE_LEVELS = r1.levels || _consoleSandbox.CONSOLE_LEVELS;
|
|
return {
|
|
name: "ConsoleLogs",
|
|
setup: (a0) => {
|
|
const options = a0.getOptions();
|
|
const { enableLogs, normalizeDepth = 3, normalizeMaxBreadth = 1000 } = options;
|
|
if (enableLogs) {
|
|
addConsoleInstrumentationHandler(({ args, level }) => {
|
|
if (getClient() === a0 && CONSOLE_LEVELS.includes(level)) {
|
|
const r15 = args[0];
|
|
const r14 = args.slice(1);
|
|
if (level !== "assert") {
|
|
const r47 = args.length > 1 && typeof args[0] === "string" && !hasConsoleSubstitutions(args[0]);
|
|
const attributes2 = {
|
|
...attributes
|
|
};
|
|
const r56 = r47 ? createConsoleTemplateAttributes(r15, r14) : {};
|
|
const r4 = level === "log";
|
|
HermesBuiltin.copyDataProperties(attributes2, r56);
|
|
_INTERNAL_captureLog({
|
|
level: r4 ? "info" : level,
|
|
message: formatConsoleArgs(args, normalizeDepth, normalizeMaxBreadth),
|
|
severityNumber: r4 ? 10 : void 0,
|
|
attributes: attributes2
|
|
});
|
|
} else if (!r15) {
|
|
_INTERNAL_captureLog({
|
|
level: "error",
|
|
message: r14.length > 0 ? `Assertion failed: ${formatConsoleArgs(r14, normalizeDepth, normalizeMaxBreadth)}` : "Assertion failed",
|
|
attributes
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} else if (DEBUG_BUILD) {
|
|
debug.warn("`enableLogs` is not enabled, ConsoleLogs integration disabled");
|
|
}
|
|
}
|
|
};
|
|
});
|