PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 4.2.10
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v4.2.10
4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 All 134 releases
optimole-wp / assets / js / modules / logger.js

logger.js in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 4.2.10, at assets/js/modules/logger.js

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Optimole Logger Module
3 * Provides centralized logging functionality with debug mode support
4 */
5
6 /**
7 * Create utility logger with simplified structure
8 */
9 export const optmlLogger = {
10 /**
11 * Check if debug mode is enabled
12 * @returns {boolean} True if debug mode is active
13 */
14 isDebug: function() {
15 return new URLSearchParams(location.search).has('optml_debug') ||
16 localStorage.getItem('optml_debug') !== null;
17 },
18
19 /**
20 * Generic log method
21 * @param {string} level - Log level (info, warn, error)
22 * @param {...any} args - Arguments to log
23 */
24 log: function(level, ...args) {
25 if (this.isDebug()) {
26 console[level]('[Optimole]', ...args);
27 }
28 },
29
30 /**
31 * Log info messages
32 * @param {...any} args - Arguments to log
33 */
34 info: function(...args) {
35 this.log('info', ...args);
36 },
37
38 /**
39 * Log warning messages
40 * @param {...any} args - Arguments to log
41 */
42 warn: function(...args) {
43 this.log('warn', ...args);
44 },
45
46 /**
47 * Log error messages
48 * @param {...any} args - Arguments to log
49 */
50 error: function(...args) {
51 this.log('error', ...args);
52 },
53
54 /**
55 * Log table data
56 * @param {Object|Array} data - Data to display in table format
57 */
58 table: function(data) {
59 if (this.isDebug()) {
60 console.log('[Optimole] Table:');
61 console.table(data);
62 }
63 }
64 };
65