JavaScript Logger
WP3dConfUtils exposes a lightweight logger that is silent by default. It does not output anything to the browser console unless explicitly enabled. The enabled state is stored in localStorage and persists across page reloads — so there is zero noise for end users who happen to open DevTools.
Enabling & Disabling
Run these directly in your browser’s developer console:
// Turn logging on
WP3dConfUtils.enableLogger();
// Turn logging off
WP3dConfUtils.disableLogger();
Methods
const { log, warn, error, info, debug } = window.WP3dConfUtils;
| Method | Maps to | Description |
|---|---|---|
log(...args) | console.log | General output |
warn(...args) | console.warn | Non-critical warnings |
error(...args) | console.error | Errors |
info(...args) | console.info | Informational messages |
debug(...args) | console.debug | Verbose debug output |
All methods accept any number of arguments, identical to their native console counterparts.
Usage
window.addEventListener('wp3dconf/frontend:ready', function() {
const { addAction } = window.WP3dConf;
const { log, warn } = window.WP3dConfUtils;
addAction('wp3dconf/frontend/layer/activated', function({ uid, layer }) {
log('Layer activated:', uid, layer);
}, 10);
addAction('wp3dconf/frontend/data/priceUpdated', function({ store }) {
log('Price updated:', store.price);
}, 10);
});
window.addEventListener('wp3dconf/editor:ready', function() {
const { addAction } = window.WP3dConf;
const { log, warn } = window.WP3dConfUtils;
addAction('wp3dconf/editor/configurator-saved', function({ store }) {
log('Configurator saved. Layer count:', Object.keys(store.layers).length);
}, 10);
addAction('wp3dconf/editor/layer-deleted', function({ layer }) {
warn('Layer deleted — this cannot be undone:', layer);
}, 10);
});