@crimsonsunset/jsg-logger 1.5.2 → 1.5.3

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
@@ -8,13 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
  ### Added
11
- - None
11
+ - **Conditional DevTools Bundling** - DevTools panel now optional via config, with tree-shaking support
12
+ - Added `devtools.enabled` config flag (default: `false`)
13
+ - Moved Preact & Evergreen UI to optional peerDependencies
14
+ - When disabled, devtools code is tree-shaken out (zero bundle impact)
15
+ - When enabled, requires peer dependencies: `npm install preact evergreen-ui`
16
+ - Function constructor used for dynamic imports to bypass Vite static analysis
12
17
 
13
- ### Changed
14
- - None
18
+ ### Changed
19
+ - **DevTools Dependencies** - Preact and Evergreen UI moved to peerDependencies for optional installation
20
+ - **DevTools Import** - Uses Function constructor instead of template literals to prevent Vite static analysis failures
15
21
 
16
22
  ### Fixed
17
- - None
23
+ - **Vite Build Failures** - Fixed dynamic import issues that caused Vite dev server startup failures
24
+ - **DevTools Bundle Size** - Zero impact when disabled (default), only loads when explicitly enabled
18
25
 
19
26
  ## [1.5.2] - 2025-10-25 🐛 **PATCH: CLI Formatter Custom Component Display**
20
27
 
package/README.md CHANGED
@@ -4,16 +4,19 @@
4
4
 
5
5
  A sophisticated, fully generic logging system that automatically detects its environment (browser, CLI, server) and provides optimal logging experience for any JavaScript project, with powerful file-level overrides and granular control.
6
6
 
7
+ > 🎮 **[Try the Interactive DevTools Playground →](https://logger.joesangiorgio.com/)**
8
+ > Test all features in your browser with live examples and real-time controls!
9
+
7
10
  ## ✨ Features
8
11
 
9
- - 🎯 **100% Generic** - *New in v1.2.0!* Zero hardcoded assumptions, works with any project type
12
+ - 🎯 **100% Generic** - Zero hardcoded assumptions, works with any project type
10
13
  - 🚀 **Zero-Boilerplate Integration** - Eliminates 200+ lines of project setup code
11
14
  - 🔧 **Auto-Discovery Components** - Both camelCase and kebab-case component access
12
15
  - ⚡ **Built-in Performance Logging** - Static utilities with auto-getInstance
13
16
  - 🛡️ **Non-Destructive Error Handling** - Missing components log but don't break apps
14
- - 🎨 **Custom Component Names** - *New in v1.5.0!* Use ANY component name, auto-generated styling
15
- - 🔧 **Force Environment Override** - *New in v1.5.0!* Override auto-detection for CLI tools
16
- - 🧠 **Enhanced Environment Detection** - *New in v1.5.0!* Robust CLI detection with fallbacks
17
+ - 🎨 **Custom Component Names** - Use ANY component name, auto-generated styling
18
+ - 🔧 **Force Environment Override** - Override auto-detection for CLI tools
19
+ - 🧠 **Enhanced Environment Detection** - Robust CLI detection with fallbacks
17
20
  - 🎨 **Beautiful Visual Output** - Emoji, colors, and structured context display
18
21
  - 📱 **Multi-Environment** - Browser console, terminal, and production JSON
19
22
  - 🏪 **Log Store** - In-memory storage for debugging and popup interfaces
@@ -27,14 +30,12 @@ A sophisticated, fully generic logging system that automatically detects its env
27
30
 
28
31
  ## 🚀 Quick Start
29
32
 
30
- ### **v1.5.0: Custom Components & Force Environment - Perfect for CLI Tools!**
31
-
32
- > **✨ New in v1.5.0:** Use ANY component name (not just pre-defined ones) and force CLI mode for terminal applications!
33
+ ### **Custom Components & Force Environment for CLI Tools**
33
34
 
34
35
  ```javascript
35
36
  import JSGLogger from '@crimsonsunset/jsg-logger';
36
37
 
37
- // ✨ NEW: Force environment for CLI tools (fixes terminal detection)
38
+ // Force environment for CLI tools (fixes terminal detection)
38
39
  const logger = JSGLogger.getInstanceSync({
39
40
  forceEnvironment: 'cli', // Forces pretty terminal output
40
41
  globalLevel: 'info',
@@ -46,7 +47,7 @@ const logger = JSGLogger.getInstanceSync({
46
47
  }
47
48
  });
48
49
 
49
- // ✨ NEW: Custom components work immediately
50
+ // Custom components work immediately
50
51
  const sysLog = logger.getComponent('system');
51
52
  sysLog.info('✓ macOS version compatible', { version: '14.2', build: '23C64' });
52
53
  // Output: Pretty formatted terminal output with colors AND context data!
@@ -59,12 +60,10 @@ installLog.info('✓ Applications installed', { installed: 25, duration: '5m' })
59
60
  // 21:32:11.8 📦 [INSTALLER] ✓ Applications installed
60
61
  // ├─ installed: 25
61
62
  // └─ duration: 5m
62
- // No more JSON blobs in terminal! 🎉
63
+ // No more JSON blobs in terminal!
63
64
  ```
64
65
 
65
- ### **v1.2.0: Fully Generic Design - Works with Any Project!**
66
-
67
- > **⚠️ Breaking Change:** v1.2.0 requires defining components in your logger-config.json. The logger is now 100% generic with no hardcoded assumptions.
66
+ ### **Standard Usage**
68
67
 
69
68
  ```javascript
70
69
  import JSGLogger from '@crimsonsunset/jsg-logger';
@@ -84,12 +83,12 @@ const startTime = performance.now();
84
83
  // ... do work ...
85
84
  JSGLogger.logPerformance('Page Generation', startTime, 'api');
86
85
 
87
- // ✨ NEW: Custom components auto-created on demand
86
+ // Custom components auto-created on demand
88
87
  const dynamicLogger = logger.getComponent('new-feature');
89
88
  dynamicLogger.info('Auto-created component!'); // Works immediately
90
89
  ```
91
90
 
92
- ### **Traditional Usage (Still Supported)**
91
+ ### **Alternative Usage**
93
92
 
94
93
  ```javascript
95
94
  import logger from '@crimsonsunset/jsg-logger';
@@ -119,7 +118,7 @@ This allows surgical debugging - you can turn on trace logging for just one prob
119
118
 
120
119
  ## ⚙️ **Advanced Configuration**
121
120
 
122
- ### **Force Environment Override** ✨ *New in v1.5.0*
121
+ ### **Force Environment Override**
123
122
 
124
123
  Perfect for CLI tools that get mis-detected as "server" mode:
125
124
 
@@ -153,7 +152,7 @@ Or in `logger-config.json`:
153
152
  - Testing different output formats
154
153
  - Production deployments with specific requirements
155
154
 
156
- ### **Custom Component Names** ✨ *New in v1.5.0*
155
+ ### **Custom Component Names**
157
156
 
158
157
  Use ANY component name - no need to pre-define in COMPONENT_SCHEME:
159
158
 
@@ -229,6 +228,9 @@ log4.info('This works!'); // Uses auto-generated styling
229
228
  "jsonPayload": false
230
229
  }
231
230
  }
231
+ },
232
+ "devtools": {
233
+ "enabled": false
232
234
  }
233
235
  }
234
236
  ```
@@ -351,7 +353,7 @@ logger.controls.addFileOverride('src/popup.js', {
351
353
 
352
354
  ### **Context Data**
353
355
 
354
- ✨ **New in v1.5.0:** Context data now displays in CLI/terminal mode with tree formatting!
356
+ Context data displays in CLI/terminal mode with tree formatting:
355
357
 
356
358
  ```javascript
357
359
  logger.api.error('Request failed', {
@@ -414,12 +416,10 @@ logger.controls.getTimestampMode() // Get current mode
414
416
  logger.controls.getTimestampModes() // List available modes
415
417
  ```
416
418
 
417
- ### **System Controls**
419
+ ### **DevTools Panel Controls**
418
420
  ```javascript
419
- logger.controls.refresh() // Refresh all loggers
420
- logger.controls.reset() // Reset to defaults
421
- logger.controls.getConfigSummary() // Get config summary
422
- logger.controls.getStats() // Get logging stats
421
+ logger.controls.enableDevPanel() // Enable DevTools panel (requires devtools.enabled: true)
422
+ logger.controls.disableDevPanel() // Disable DevTools panel
423
423
  ```
424
424
 
425
425
  ## 📊 **Log Store & Statistics**
@@ -509,26 +509,15 @@ The logger automatically detects its environment and uses optimal implementation
509
509
  - **CLI**: Uses pino-colada for beautiful terminal output
510
510
  - **Server**: Uses structured JSON for production logging
511
511
 
512
- ### **Enhanced CLI Detection** ✨ *Improved in v1.5.0*
512
+ ### **Enhanced CLI Detection**
513
513
 
514
- The CLI detection now checks multiple signals:
514
+ The CLI detection checks multiple signals:
515
515
  1. **TTY Check**: `process.stdout.isTTY` or `process.stderr.isTTY`
516
516
  2. **Terminal Environment**: `process.env.TERM` or `process.env.COLORTERM`
517
517
  3. **Non-CI Context**: Not running in CI/GitHub Actions
518
518
 
519
519
  This fixes detection issues in various terminal contexts where `isTTY` may be undefined.
520
520
 
521
- ### **Force Environment Override** ✨ *New in v1.5.0*
522
-
523
- If auto-detection fails, you can force the environment:
524
-
525
- ```javascript
526
- const logger = JSGLogger.getInstanceSync({
527
- forceEnvironment: 'cli', // Override auto-detection
528
- // ... rest of config
529
- });
530
- ```
531
-
532
521
  **Why Browser is Different:**
533
522
  Our testing revealed that Pino's browser detection was interfering with custom formatters, especially in Chrome extensions. By creating a custom direct browser logger that bypasses Pino entirely, we achieved:
534
523
  - Perfect emoji and color display
@@ -567,6 +556,42 @@ logger.controls.addFileOverride('src/popup.js', { // Debug popup
567
556
  });
568
557
  ```
569
558
 
559
+ ## 🎛️ **DevTools Panel (Optional)**
560
+
561
+ JSG Logger includes an optional DevTools panel for visual debugging. The panel is **disabled by default** to keep bundle size minimal.
562
+
563
+ ### **Enabling DevTools**
564
+
565
+ 1. **Enable in config:**
566
+ ```json
567
+ {
568
+ "devtools": {
569
+ "enabled": true
570
+ }
571
+ }
572
+ ```
573
+
574
+ 2. **Install peer dependencies** (only needed when devtools enabled):
575
+ ```bash
576
+ npm install preact evergreen-ui
577
+ ```
578
+
579
+ 3. **Enable the panel:**
580
+ ```javascript
581
+ // Enable DevTools panel (only works if devtools.enabled: true in config)
582
+ await logger.controls.enableDevPanel();
583
+ ```
584
+
585
+ ### **DevTools Features**
586
+
587
+ - 🎛️ Visual component filter controls
588
+ - 📊 Real-time log statistics
589
+ - 🔧 Runtime level adjustment
590
+ - ⚙️ Display option toggles
591
+ - 📈 Component-level monitoring
592
+
593
+ **Note:** When `devtools.enabled: false` (default), devtools dependencies are completely tree-shaken out, resulting in zero bundle impact. Only enable when you need the visual debugging interface.
594
+
570
595
  ## 🔧 **Browser Developer Tools**
571
596
 
572
597
  In browser environments, runtime controls are available globally:
@@ -577,6 +602,7 @@ JSG_Logger.enableDebugMode();
577
602
  JSG_Logger.setDisplayOption('level', true);
578
603
  JSG_Logger.addFileOverride('src/popup.js', { level: 'trace' });
579
604
  JSG_Logger.getStats();
605
+ JSG_Logger.enableDevPanel(); // Enable DevTools panel (requires devtools.enabled: true)
580
606
  ```
581
607
 
582
608
  ## ⚠️ **Disclaimer**
@@ -133,7 +133,7 @@ export class ConfigManager {
133
133
 
134
134
  try {
135
135
  // Try dynamic import first (works with ES modules)
136
- const module = await import(path, { assert: { type: 'json' } });
136
+ const module = await import(/* @vite-ignore */ path, { assert: { type: 'json' } });
137
137
  return module.default || module;
138
138
  } catch (error) {
139
139
  try {
@@ -156,7 +156,7 @@ export class ConfigManager {
156
156
  async _loadConfigBrowserImport(path) {
157
157
  try {
158
158
  // Some bundlers can handle dynamic imports of JSON files
159
- const module = await import(path);
159
+ const module = await import(/* @vite-ignore */ path);
160
160
  return module.default || module;
161
161
  } catch (error) {
162
162
  return null;
@@ -33,5 +33,8 @@
33
33
  }
34
34
  },
35
35
  "fileOverrides": {
36
+ },
37
+ "devtools": {
38
+ "enabled": false
36
39
  }
37
40
  }