@crimsonsunset/jsg-logger 1.7.5 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,59 @@ All notable changes to the JSG Logger project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.7.6] - 2025-11-06 🎛️ **DevTools Singleton Fix & Logging Improvements**
9
+
10
+ ### Added
11
+ - **Static `getControls()` Method** - Added `JSGLogger.getControls()` static method for accessing singleton controls
12
+ - Returns `controls` object from existing singleton instance without triggering initialization
13
+ - Provides clean access point for DevTools panel to get logger controls
14
+ - Returns `null` if singleton not yet initialized
15
+ - Prevents DevTools from creating new logger instance when accessing controls
16
+
17
+ ### Fixed
18
+ - **DevTools Singleton Re-initialization** - Fixed DevTools panel creating new logger instance on open
19
+ - DevTools panel now uses `JSGLogger.getControls()` and `JSGLogger.getInstanceSync()` instead of top-level imports
20
+ - Prevents loss of component loggers when DevTools opens
21
+ - Component loggers now persist correctly across DevTools open/close cycles
22
+ - Fixed issue where opening DevTools would reset logger to default config with only "core" component
23
+ - **Component List Duplicates** - Fixed duplicate component entries in DevTools UI
24
+ - `listComponents()` now returns only kebab-case names from config (e.g., `devtools-ui`)
25
+ - Removed camelCase aliases from component list display
26
+ - CamelCase access still available via `logger.components.camelCase()` getters for backward compatibility
27
+ - UI now shows clean, non-duplicated component list
28
+ - **Circular Reference Errors** - Fixed circular reference errors when logging objects
29
+ - Added circular reference detection in browser formatter `displayContextData()` function
30
+ - Removed problematic object logging (theme objects, logger instances, panel instances)
31
+ - Error logging now extracts only safe properties (`message`, `stack`) to avoid serialization issues
32
+ - DevTools panel initialization no longer throws circular reference errors
33
+ - **DevTools Logging Format** - Fixed DevTools logs to use proper JSG logger formatting
34
+ - Replaced all `console.log()` calls in DevTools components with JSG logger calls
35
+ - DevTools logs now show timestamps, emojis, colors, and structured output
36
+ - All DevTools component logs (DevToolsPanel, GlobalControls, DisplayControls) use `devtools-ui` component logger
37
+ - Logs now match standard JSG logger format instead of plain `[JSG-DEVTOOLS]` console messages
38
+
39
+ ### Changed
40
+ - **DevTools Panel Logger Access** - Updated DevTools panel to use singleton access pattern
41
+ - `panel-entry.jsx` now imports `{ JSGLogger }` class instead of default export
42
+ - Uses `JSGLogger.getInstanceSync()` for full logger instance access
43
+ - Uses `JSGLogger.getControls()` for controls API access
44
+ - Prevents module-level initialization from creating new singleton instance
45
+ - **Component Alias Creation** - Disabled camelCase aliases in `this.loggers` object
46
+ - Commented out `createAliases()` calls in `init()` and `initSync()` methods
47
+ - CamelCase aliases no longer added to `this.loggers` (prevents duplicates in `listComponents()`)
48
+ - CamelCase access still works via `components` getters (e.g., `logger.components.devtoolsUi()`)
49
+
50
+ ### Technical Details
51
+ - **Files Modified**:
52
+ - `index.js` - Added `getControls()` static method, disabled `createAliases()` calls, updated `listComponents()` to use `configManager.getAvailableComponents()`
53
+ - `devtools/src/panel-entry.jsx` - Changed to use singleton access pattern, removed top-level logger import
54
+ - `devtools/src/components/DevToolsPanel.jsx` - Replaced `console.log` with JSG logger calls
55
+ - `devtools/src/components/GlobalControls.jsx` - Replaced `console.log` with JSG logger calls
56
+ - `devtools/src/components/DisplayControls.jsx` - Replaced all `console.log/warn` with JSG logger calls
57
+ - `devtools/src/App.jsx` - Fixed circular reference errors in error logging
58
+ - `formatters/browser-formatter.js` - Added circular reference detection in `displayContextData()`
59
+ - **Result**: DevTools panel now correctly uses singleton instance, component loggers persist, no duplicate entries, proper logging format throughout
60
+
8
61
  ## [1.7.5] - 2025-11-06 🎛️ **DevTools Panel UX Improvements**
9
62
 
10
63
  ### Added
@@ -166,7 +166,20 @@ function extractContextData(logData) {
166
166
  function displayContextData(contextData) {
167
167
  Object.entries(contextData).forEach(([key, value]) => {
168
168
  if (typeof value === 'object' && value !== null) {
169
- console.log(` ├─ %c${key}:`, 'color: #00C896; font-weight: bold;', value);
169
+ // Check for circular references before logging
170
+ try {
171
+ // Try to stringify to detect circular references
172
+ JSON.stringify(value);
173
+ console.log(` ├─ %c${key}:`, 'color: #00C896; font-weight: bold;', value);
174
+ } catch (error) {
175
+ // Circular reference detected - log a safe representation
176
+ if (error.message.includes('circular')) {
177
+ console.log(` ├─ %c${key}:`, 'color: #00C896; font-weight: bold;', '[Circular Reference]', value);
178
+ } else {
179
+ // Other error - log the object directly (browser console can handle it)
180
+ console.log(` ├─ %c${key}:`, 'color: #00C896; font-weight: bold;', value);
181
+ }
182
+ }
170
183
  } else {
171
184
  console.log(` ├─ %c${key}: %c${value}`, 'color: #00C896; font-weight: bold;', 'color: inherit;');
172
185
  }
package/index.js CHANGED
@@ -140,7 +140,9 @@ class JSGLogger {
140
140
  });
141
141
 
142
142
  // Create legacy compatibility aliases
143
- this.createAliases();
143
+ // Removed: camelCase aliases no longer added to this.loggers
144
+ // Use logger.components.camelCase() or logger.getComponent('kebab-case') instead
145
+ // this.createAliases();
144
146
 
145
147
  // Add utility methods
146
148
  this.addUtilityMethods();
@@ -215,7 +217,9 @@ class JSGLogger {
215
217
  });
216
218
 
217
219
  // Create legacy compatibility aliases
218
- this.createAliases();
220
+ // Removed: camelCase aliases no longer added to this.loggers
221
+ // Use logger.components.camelCase() or logger.getComponent('kebab-case') instead
222
+ // this.createAliases();
219
223
 
220
224
  // Add utility methods
221
225
  this.addUtilityMethods();
@@ -416,7 +420,7 @@ class JSGLogger {
416
420
  },
417
421
 
418
422
  // Component controls
419
- listComponents: () => Object.keys(this.loggers),
423
+ listComponents: () => configManager.getAvailableComponents(),
420
424
  enableDebugMode: () => {
421
425
  Object.keys(this.loggers).forEach(component => {
422
426
  if (this.loggers[component]) {
@@ -774,6 +778,15 @@ class JSGLogger {
774
778
  return duration;
775
779
  }
776
780
  }
781
+
782
+ /**
783
+ * Get singleton controls without triggering initialization
784
+ * Returns the controls object from the current singleton instance if it exists
785
+ * @returns {Object|null} Controls object or null if singleton not initialized
786
+ */
787
+ static getControls() {
788
+ return JSGLogger._enhancedLoggers?.controls || null;
789
+ }
777
790
  }
778
791
 
779
792
  // Initialize synchronously with default config for immediate use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crimsonsunset/jsg-logger",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "type": "module",
5
5
  "description": "Multi-environment logger with smart detection, file-level overrides, and beautiful console formatting. Test it live: https://logger.joesangiorgio.com/",
6
6
  "main": "index.js",