UNPKG

@applitools/eyes-playwright

Version:
45 lines (44 loc) 1.42 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint no-console: off */ function isDebugEnabled() { try { // Get query string from the topmost window (parent frame) const topWindow = window.top || window; const urlParams = new URLSearchParams(topWindow.location.search); return urlParams.get('debug') === 'true'; } catch (e) { // Cross-origin access may throw an error, fallback to current window try { const urlParams = new URLSearchParams(window.location.search); return urlParams.get('debug') === 'true'; } catch (e2) { return false; } } } function makeLog(prefix = '') { const debugEnabled = isDebugEnabled(); return { log: (...args) => { if (!debugEnabled) return; const logArgs = prefix ? [prefix, ...args] : args; console.log(...logArgs); }, warn: (...args) => { if (!debugEnabled) return; const logArgs = prefix ? [prefix, ...args] : args; console.warn(...logArgs); }, error: (...args) => { // Always show errors regardless of debug mode const logArgs = prefix ? [prefix, ...args] : args; console.error(...logArgs); }, }; } exports.default = makeLog;