// Opt-in flow logging for the toolkit. OFF by default so the published package // is quiet in production. Turn it on either from code — `setDebug(true)` — or at // runtime from the browser console: `globalThis.__EDGE_MCP_DEBUG__ = true`. let enabled = false; // Colored prefix so the toolkit's lines pop in a busy console. `%c` styles only // the prefix segment; the rest of the line stays at the console's default color. const PREFIX = '%c[edge-mcp]'; const PREFIX_STYLE = 'color:#c084fc;font-weight:bold'; /** Enable or disable the toolkit's `[edge-mcp]` flow logs. */ export function setDebug(on: boolean): void { enabled = on; } function isOn(): boolean { if (enabled) return true; try { return Boolean((globalThis as { __EDGE_MCP_DEBUG__?: unknown }).__EDGE_MCP_DEBUG__); } catch { return false; } } /** Log a flow event when debug is on. No-op otherwise. */ export function debugLog(...args: unknown[]): void { if (!isOn()) return; // eslint-disable-next-line no-console console.info(PREFIX, PREFIX_STYLE, ...args); } /** * Warn with the colored `[edge-mcp]` prefix. Always shown (NOT gated by debug): * these signal real problems (e.g. a failed native-registry mirror) that should * surface even with flow logging off. */ export function edgeWarn(...args: unknown[]): void { // eslint-disable-next-line no-console console.warn(PREFIX, PREFIX_STYLE, ...args); }