diff --git a/packages/child/log.js b/packages/child/log.js index e2ac78e77..a259012ab 100644 --- a/packages/child/log.js +++ b/packages/child/log.js @@ -32,15 +32,8 @@ export function getElementName(el) { } } -// function elementSnippet(el, maxChars = 30) { -// const outer = el?.outerHTML?.toString() - -// if (!outer) return el - -// return outer.length < maxChars -// ? outer -// : `${outer.slice(0, maxChars).replaceAll('\n', ' ')}...` -// } +const BOLD = 'font-weight: bold;' +const NORMAL = 'font-weight: normal;' // TODO: remove .join(' '), requires major test updates const formatLogMsg = (...msg) => @@ -53,7 +46,7 @@ export const log = (...msg) => // eslint-disable-next-line no-unused-vars export const info = (...msg) => // eslint-disable-next-line no-console - logging && console?.info(`[iframe-resizer][${id}]`, ...msg) + logging && console?.info(`%c[iframe-resizer][${id}]%c`, BOLD, NORMAL, ...msg) export const warn = (...msg) => // eslint-disable-next-line no-console diff --git a/packages/child/perf.js b/packages/child/perf.js index 3d0084902..1bac807b6 100644 --- a/packages/child/perf.js +++ b/packages/child/perf.js @@ -14,7 +14,7 @@ const usedTags = new WeakSet() const addUsedTag = (el) => typeof el === 'object' && usedTags.add(el) -let lastPerfEl = null +// let lastPerfEl = null let perfEl = null let details = {} @@ -28,18 +28,20 @@ function usedEl(detail, duration) { details = detail - if (usedTags.has(perfEl) || lastPerfEl === perfEl || (hasTags && len <= 1)) { + if ( + usedTags.has(perfEl) /* || lastPerfEl === perfEl */ || + (hasTags && len <= 1) + ) return - } if (!logging) addUsedTag(perfEl) - lastPerfEl = perfEl + // lastPerfEl = perfEl info( - `\n${Side} position calculated from:`, + `\n ${Side} position calculated from:`, perfEl, - `\nParsed ${len} ${hasTags ? 'tagged' : 'potentially overflowing'} elements in ${round(duration)}ms`, + `\n Parsed ${len} ${hasTags ? 'tagged' : 'potentially overflowing'} elements in ${round(duration)}ms`, ) } diff --git a/packages/core/index.js b/packages/core/index.js index c87a98a08..b8041abde 100644 --- a/packages/core/index.js +++ b/packages/core/index.js @@ -6,17 +6,10 @@ import { VERSION, } from '../common/consts' import { addEventListener, removeEventListener } from '../common/listeners' -import { - advise, - info, - log, - setLogEnabled, - setLogSettings, - warn, -} from '../common/log' // import modal from '../common/modal' import setMode, { getModeData, getModeLabel } from '../common/mode' import { once } from '../common/utils' +import { advise, log, setLogEnabled, setLogSettings, vInfo, warn } from './log' import defaults from './values/defaults' import page from './values/page' import settings from './values/settings' @@ -1035,7 +1028,7 @@ The sizeWidth, sizeHeight and autoResize options have been rep if (vAdvised || mode < 0) return vAdvised = true - info(`v${VERSION} (${getModeLabel(mode)})`) + vInfo(`v${VERSION} (${getModeLabel(mode)})`) if (mode < 1) advise('Parent', getModeData(3)) } diff --git a/packages/common/log.js b/packages/core/log.js similarity index 83% rename from packages/common/log.js rename to packages/core/log.js index 1c03f56cd..8748c95a1 100644 --- a/packages/common/log.js +++ b/packages/core/log.js @@ -1,7 +1,10 @@ -import formatAdvise from './format-advise' +import formatAdvise from '../common/format-advise' const msgId = '[iframe-resizer]' +const BOLD = 'font-weight: bold;' +// const NORMAL = 'font-weight: normal;' + let settings = {} let logEnabled = false @@ -42,6 +45,10 @@ export const log = (iframeId, ...msg) => export const info = (iframeId, ...msg) => output('info', iframeId, ...msg) +export const vInfo = (msg) => + // eslint-disable-next-line no-console + console.info(`%c[iframe-resizer] ${msg}`, BOLD) + export const warn = (iframeId, ...msg) => output('warn', iframeId, ...msg) export const advise = (iframeId, msg) => diff --git a/packages/core/values/defaults.js b/packages/core/values/defaults.js index 567903604..3928f73fc 100644 --- a/packages/core/values/defaults.js +++ b/packages/core/values/defaults.js @@ -1,4 +1,4 @@ -import { advise } from '../../common/log' +import { advise } from '../log' import settings from './settings' const onReadyDeprecated = (messageData) => { diff --git a/packages/jquery/plugin.js b/packages/jquery/plugin.js index 7207b12e9..e37134df7 100644 --- a/packages/jquery/plugin.js +++ b/packages/jquery/plugin.js @@ -1,6 +1,6 @@ import connectResizer from '@iframe-resizer/core' -import { warn } from '../common/log' +import { warn } from '../core/log' switch (true) { case window.jQuery === undefined: diff --git a/packages/parent/iife.js b/packages/parent/iife.js index 93d3c8e54..4a702f341 100644 --- a/packages/parent/iife.js +++ b/packages/parent/iife.js @@ -1,4 +1,4 @@ -import { advise } from '../common/log' +import { advise } from '../core/log' import createIframeResize from './factory' window.iframeResize = createIframeResize() diff --git a/packages/parent/umd.js b/packages/parent/umd.js index 4597084bd..43dd88be5 100644 --- a/packages/parent/umd.js +++ b/packages/parent/umd.js @@ -1,4 +1,4 @@ -import { advise } from '../common/log' +import { advise } from '../core/log' import createIframeResize from './factory' const iframeResize = createIframeResize()