@crimsonsunset/jsg-logger 1.6.0 → 1.7.2

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -128,10 +128,13 @@
128
128
  - [ ] **Bulk Actions** - Select multiple components for batch operations
129
129
  - [ ] **Preset Configurations** - Save/load common debug configurations
130
130
 
131
- ### **Phase 4: Data & Persistence** 🎯 FUTURE
131
+ ### **Phase 4: State Management & Persistence** 🎯 FUTURE
132
+ - [ ] **Zustand Integration** - Centralized state management for DevTools UI
133
+ - [ ] **Floating Button Position** - Persist position across reloads (first Zustand feature)
134
+ - [ ] **Panel Open/Closed State** - Remember panel state across page reloads
135
+ - [ ] **Display Settings** - Persist display toggles and preferences
136
+ - [ ] **Component Filter States** - Remember component level selections
132
137
  - [ ] **Configuration Export/Import** - Save panel settings to JSON
133
- - [ ] **Session Persistence** - Remember panel state across page reloads
134
- - [ ] **Local Storage** - Persist component preferences per site
135
138
  - [ ] **Configuration Sharing** - Export/import debug configurations
136
139
  - [ ] **Preset Templates** - Common configurations for different scenarios
137
140
 
@@ -14,12 +14,74 @@
14
14
 
15
15
  ---
16
16
 
17
- **Date:** October 25, 2025
18
- **Session Goal:** 🎯 **Critical CLI Tool Fixes** - Resolve environment detection and custom component blockers
19
- **Status:** ✅ **COMPLETE** - v1.5.0 shipped with all critical fixes
17
+ **Date:** October 28, 2025
18
+ **Session Goal:** 🎨 **Phase 7.1: Display Controls Panel** - Real-time preview with display toggles
19
+ **Status:** ✅ **COMPLETE** - All display controls implemented and working
20
20
 
21
21
  ## 🎉 MAJOR ACCOMPLISHMENTS THIS SESSION
22
22
 
23
+ ### ✅ Phase 7.1 Display Controls Complete (October 28, 2025) 🎨→✅
24
+ - **📊 Live Preview in Sticky Header** - Real-time log preview that updates instantly
25
+ - Shows sample log with all elements (timestamp, emoji, component, level, message, JSON, stack trace)
26
+ - Updates immediately as controls are toggled
27
+ - Stays visible while scrolling through other controls
28
+ - Professional monospace styling matching console output
29
+ - **⏱️ Timestamp Mode Control** - Button group with 4 modes
30
+ - Absolute: `22:15:30.1` (milliseconds precision)
31
+ - Readable: `10:15 PM` (12-hour format)
32
+ - Relative: `2s ago` (time since)
33
+ - Off: Hidden (no timestamp)
34
+ - Active button highlighted with primary appearance
35
+ - **🎛️ 6 Display Toggle Switches** - Granular control over log elements
36
+ - Emoji: Show/hide level emoji (🌐, 🚨, etc.)
37
+ - Component: Show/hide [COMPONENT-NAME] tags
38
+ - Level Name: Show/hide level text (INFO, DEBUG, etc.)
39
+ - Message: Always on (disabled - can't hide messages)
40
+ - JSON Data: Show/hide context data trees
41
+ - Stack Trace: Show/hide error stack traces
42
+ - **✅ Bulk Operations** - Quick control actions
43
+ - All On: Enable all display options
44
+ - All Off: Disable all (except message)
45
+ - Reset: Restore default settings
46
+ - **🏗️ Clean Architecture** - Simplified layout with no sections
47
+ - Removed all subheadings and dividers
48
+ - Everything in one sticky container
49
+ - Only Component Filters and Global Controls scroll
50
+ - Single divider at the bottom of scrolling content
51
+ - **🔧 API Integration** - Full logger.controls integration
52
+ - `getDisplayConfig()` loads initial state
53
+ - `getTimestampMode()` loads timestamp setting
54
+ - `setDisplayOption()` applies changes to console
55
+ - `setTimestampMode()` updates timestamp format
56
+ - State managed via parent component callback
57
+
58
+ ### **Technical Implementation**
59
+ - **DisplayControls.jsx** (~350 lines)
60
+ - Exported LogPreview component for header use
61
+ - State management with `onStateChange` callback
62
+ - Timestamp button group (replaced SegmentedControl)
63
+ - 6 toggle switches in 2-column grid
64
+ - Bulk control buttons
65
+ - **PanelContainer.jsx** (updated)
66
+ - LogPreview and DisplayControls in sticky header
67
+ - State management for preview rendering
68
+ - Single scrolling content area
69
+ - Clean layout with one border at bottom
70
+ - **ComponentFilters.jsx** (simplified)
71
+ - Removed "🎚️ Log Levels" heading
72
+ - Reduced spacing for compact layout
73
+ - **GlobalControls.jsx** (simplified)
74
+ - Removed "🌐 Global Controls" heading
75
+ - Cleaner integration with overall layout
76
+
77
+ ### **Real-World Impact**
78
+ Phase 7.1 completes the foundation for comprehensive DevTools UI:
79
+ - **Before**: Only basic component filtering, missing 80% of logger capabilities
80
+ - **After**: Display controls expose all visual formatting options with live preview
81
+ - **Next**: Phase 7.2 will add component management (emoji/color pickers, bulk operations)
82
+
83
+ ## 🎉 PREVIOUS SESSION ACCOMPLISHMENTS
84
+
23
85
  ### ✅ Critical CLI Tool Fixes Complete (October 25, 2025) 🚨→✅
24
86
  - **🎨 CLI Context Data Display Fixed** - Replaced pino-colada with custom formatter
25
87
  - Context data now renders as indented tree in terminal
package/docs/roadmap.md CHANGED
@@ -20,10 +20,10 @@
20
20
  ---
21
21
 
22
22
  ## 🎯 Current Status
23
- **Last Updated:** August 21, 2025
24
- **Current Phase:** DevTools Phase 2 - Evergreen UI Migration 🔧 **IN PROGRESS**
25
- **Status:** 🎨 **UI COMPLETE, DEBUGGING API INTEGRATION** - Professional DevTools UI built, fixing logger compatibility
26
- **Next Phase:** Complete DevTools Phase 2, then Phase 10 DX Enhancements
23
+ **Last Updated:** October 28, 2025
24
+ **Current Phase:** DevTools UI Enhancement (Phase 3-7) 🚀 **ACTIVE DEVELOPMENT**
25
+ **Status:** 🎨 **PHASE 7.1 COMPLETE** - Display Controls with live preview implemented
26
+ **Next Phase:** Phase 7.2 Component Management Log Viewer → Advanced Config → Statistics → UI Polish
27
27
 
28
28
  ### Progress Overview
29
29
  - ✅ **COMPLETED:** Multi-environment logger with smart detection
@@ -38,6 +38,8 @@
38
38
  - ✅ **COMPLETED:** Documentation structure (LICENSE, CHANGELOG, CONTRIBUTING)
39
39
  - ✅ **COMPLETED:** Phase 8 API Enhancement - v1.1.0 with zero-boilerplate integration
40
40
  - ✅ **COMPLETED:** Phase 9 Genericization - v1.2.0 with zero legacy references
41
+ - ✅ **COMPLETED:** Phase 6 DevTools Foundation - Working panel with Evergreen UI integration
42
+ - 🚀 **IN PROGRESS:** Phase 7 DevTools UI Enhancement - Comprehensive feature expansion
41
43
 
42
44
  ### Key Achievements
43
45
  - **🚀 BREAKTHROUGH:** Custom browser logger achieving perfect visual formatting
@@ -47,6 +49,8 @@
47
49
  - **📚 Documentation:** Comprehensive README with examples
48
50
  - **✨ PROJECT SIMPLIFICATION:** Phase 8 - 82% boilerplate reduction with v1.1.0 API enhancements
49
51
  - **🎯 FULL GENERICIZATION:** Phase 9 - 100% generic logger, zero legacy dependencies
52
+ - **🎛️ DEVTOOLS FOUNDATION:** Phase 6 - Working panel with Evergreen UI integration and runtime injection
53
+ - **📊 COMPREHENSIVE PLANNING:** Phase 7 - Identified and architected solution for exposing 80% of missing library capabilities
50
54
 
51
55
  ---
52
56
 
@@ -105,19 +109,153 @@
105
109
  - [x] docs/ folder structure
106
110
  - [x] Roadmap and session tracking
107
111
 
108
- ### **Phase 6: DevTools Panel Implementation** 🎯 FUTURE
109
- - [ ] **DevTools Panel Architecture** - Runtime-injected browser widget
110
- - [ ] **UI Components** - Preact-based filtering controls
111
- - [ ] **Panel Integration** - Floating button + collapsible sidebar
112
- - [ ] **Filter Controls** - Component toggles using existing logger.controls API
113
- - [ ] **State Persistence** - IndexedDB for panel preferences
114
- - [ ] **Real-time Filtering** - Forward console filtering without log display
112
+ ### **Phase 6: DevTools Panel Implementation** COMPLETE
113
+ - [x] **DevTools Panel Architecture** - Runtime-injected browser widget
114
+ - [x] **UI Components** - Preact-based filtering controls
115
+ - [x] **Panel Integration** - Floating button + collapsible sidebar
116
+ - [x] **Filter Controls** - Component toggles using existing logger.controls API
117
+ - [x] **State Persistence** - IndexedDB for panel preferences
118
+ - [x] **Real-time Filtering** - Forward console filtering without log display
119
+
120
+ ### **Phase 7: DevTools UI Enhancement (Phase 2)** 🚀 ACTIVE
121
+ - [x] **Display Controls Panel** - 7 toggle switches for display options with real-time preview ✅ COMPLETE
122
+ - [ ] **Enhanced Component Management** - Emoji/color pickers, add/remove components, bulk operations 🎯 NEXT
123
+ - [ ] **Integrated Log Viewer** - Real-time filtering, search, export capabilities within DevTools
124
+ - [ ] **Advanced Configuration** - Timestamp controls, environment settings, config import/export
125
+ - [ ] **Statistics Dashboard** - Analytics, charts, performance monitoring, visual trends
126
+ - [ ] **UI Architecture Polish** - Tabbed interface, responsive design, professional theming
127
+
128
+ ### **Phase 8: Advanced DevTools Features** 🎯 FUTURE
129
+ - [ ] **File Override Management** - Visual interface for file-specific logging rules
130
+ - [ ] **Performance Monitoring** - Real-time performance metrics and optimization suggestions
131
+ - [ ] **Export Utilities** - Advanced log export formats (JSON, CSV, filtered datasets)
132
+ - [ ] **Integration Guides** - Framework-specific examples and DevTools integration patterns
115
133
 
116
- ### **Phase 7: Optional Ecosystem Enhancements** 🎯 FUTURE
117
- - [ ] **Performance Monitoring** - Log performance metrics
118
- - [ ] **Export Utilities** - Save logs to file formats
119
- - [ ] **Integration Guides** - Framework-specific examples
120
- - [ ] **Restore pino-pretty Support** - Add back full pino-pretty formatter with proper browser/Node.js environment detection to avoid bundling conflicts
134
+ ---
135
+
136
+ ## 🎛️ **Phase 7: DevTools UI Enhancement - Detailed Implementation Plan**
137
+
138
+ *This section outlines the comprehensive expansion of DevTools UI to expose JSG Logger's full capabilities.*
139
+
140
+ ### **🎯 Gap Analysis Results**
141
+
142
+ **Current UI Coverage:** ~20% of JSG Logger capabilities
143
+ **Missing Features:** 80% of sophisticated library functionality not exposed in UI
144
+
145
+ **Critical Missing Categories:**
146
+ 1. **File Override Management** - Visual interface for powerful file-specific logging rules
147
+ 2. **Display Controls** - 7 individual display option toggles with real-time preview
148
+ 3. **Component Management** - Emoji/color customization, add/remove components, bulk operations
149
+ 4. **Log Viewer** - Integrated log viewing with filtering, search, and export
150
+ 5. **Advanced Configuration** - Timestamp controls, environment settings, config management
151
+ 6. **Statistics Dashboard** - Analytics, trends, performance monitoring with visualizations
152
+ 7. **UI Architecture** - Professional tabbed interface with responsive design and state persistence
153
+
154
+ ### **🚀 Implementation Phases**
155
+
156
+ #### **Phase 7.1: Display Controls Panel** ✅ COMPLETE (October 28, 2025)
157
+ **Implemented Components:**
158
+ - `devtools/src/components/DisplayControls.jsx` (created - 350 lines)
159
+ - `devtools/src/components/PanelContainer.jsx` (updated - sticky header integration)
160
+ - `devtools/src/components/ComponentFilters.jsx` (simplified - removed heading)
161
+ - `devtools/src/components/GlobalControls.jsx` (simplified - removed heading)
162
+
163
+ **Features Delivered:**
164
+ - ✅ Live preview in sticky header with real-time updates
165
+ - ✅ Timestamp mode selector (4 buttons: Absolute, Readable, Relative, Off)
166
+ - ✅ 6 toggle switches (emoji, component, level, message-disabled, JSON data, stack trace)
167
+ - ✅ Bulk operations (All On, All Off, Reset)
168
+ - ✅ Clean architecture with single sticky container
169
+ - ✅ Full API integration with logger.controls
170
+ - ✅ State management via parent callback (onStateChange)
171
+
172
+ #### **Phase 7.2: Enhanced Component Management** 🎯 NEXT
173
+ **Target Components:**
174
+ - `devtools/src/components/ComponentManager.jsx` (new)
175
+ - `devtools/src/components/ComponentEditor.jsx` (new)
176
+ - `devtools/src/components/ComponentFilters.jsx` (update)
177
+
178
+ **Features:**
179
+ - Component customization modal with emoji picker
180
+ - Color picker for component themes and styling
181
+ - Add/remove custom components with validation
182
+ - Bulk component operations (select all, reset all, apply level to multiple)
183
+ - Component import/export functionality
184
+ - Component usage statistics and recommendations
185
+
186
+ #### **Phase 7.3: Integrated Log Viewer** 🎯 FUTURE
187
+ **Target Components:**
188
+ - `devtools/src/components/LogViewer.jsx` (new)
189
+ - `devtools/src/components/LogEntry.jsx` (new)
190
+ - `devtools/src/components/LogFilters.jsx` (new)
191
+
192
+ **Features:**
193
+ - Virtualized scrolling log viewer for performance with large datasets
194
+ - Real-time log filtering by component, level, and custom criteria
195
+ - Advanced search functionality with regex support
196
+ - Log export features (JSON, CSV, plain text, filtered datasets)
197
+ - Log entry expansion showing full context data and metadata
198
+ - Integration with `logger.logStore` API for efficient data access
199
+
200
+ #### **Phase 7.4: Advanced Configuration Interface** 🎯 FUTURE
201
+ **Target Components:**
202
+ - `devtools/src/components/AdvancedConfig.jsx` (new)
203
+ - `devtools/src/components/TimestampControls.jsx` (new)
204
+ - `devtools/src/components/ConfigManager.jsx` (new)
205
+
206
+ **Features:**
207
+ - Timestamp mode selector with 4 modes and live preview
208
+ - Environment override controls with detection status
209
+ - Configuration import/export with validation and diff viewing
210
+ - Performance monitoring dashboard with metrics and recommendations
211
+ - System information panel showing environment details and capabilities
212
+
213
+ #### **Phase 7.5: Statistics & Monitoring Dashboard** 🎯 FUTURE
214
+ **Target Components:**
215
+ - `devtools/src/components/StatsDashboard.jsx` (new)
216
+ - `devtools/src/components/ComponentChart.jsx` (new)
217
+ - `devtools/src/components/PerformanceMonitor.jsx` (new)
218
+
219
+ **Features:**
220
+ - Enhanced statistics dashboard with interactive charts and graphs
221
+ - Component activity trends and usage patterns visualization
222
+ - Time-based analytics with historical data and trend analysis
223
+ - Performance metrics monitoring with optimization suggestions
224
+ - Real-time monitoring widgets with configurable alerts and thresholds
225
+
226
+ #### **Phase 7.6: UI Architecture & Professional Polish** 🎯 FUTURE
227
+ **Target Components:**
228
+ - `devtools/src/components/TabbedInterface.jsx` (new)
229
+ - `devtools/src/components/PanelContainer.jsx` (major redesign)
230
+ - `devtools/src/styles/` (new directory)
231
+
232
+ **Features:**
233
+ - Tabbed interface for organizing all panels with intuitive navigation
234
+ - Responsive design adapting to different screen sizes and orientations
235
+ - Consistent theming across all components with dark/light mode support
236
+ - Smooth animations and transitions for professional user experience
237
+ - Keyboard shortcuts for common actions and navigation
238
+ - Panel state persistence using localStorage with user preferences
239
+
240
+ ### **🎯 Success Criteria**
241
+
242
+ #### **Functionality Goals**
243
+ - ✅ **Complete API Coverage** - UI exposes 95%+ of JSG Logger's runtime capabilities
244
+ - ✅ **Superior Console Alternative** - Better UX than native browser console
245
+ - ✅ **Integrated Workflow** - All debugging needs met within single interface
246
+ - ✅ **Professional Quality** - Matches or exceeds native DevTools UI standards
247
+
248
+ #### **User Experience Goals**
249
+ - ✅ **Intuitive Navigation** - Users can find any feature within 2 clicks
250
+ - ✅ **Immediate Feedback** - All changes reflected in real-time
251
+ - ✅ **State Persistence** - User preferences and panel states survive page reloads
252
+ - ✅ **Performance** - UI remains responsive with 1000+ log entries and 50+ components
253
+
254
+ #### **Technical Goals**
255
+ - ✅ **Zero Bundle Impact** - All features load on-demand via dynamic imports
256
+ - ✅ **Responsive Design** - Works seamlessly from 1024px to 4K displays
257
+ - ✅ **Accessibility** - Full keyboard navigation and screen reader support
258
+ - ✅ **Browser Compatibility** - Works in Chrome, Firefox, Safari, and Edge
121
259
 
122
260
  ---
123
261
 
@@ -342,7 +480,24 @@ Console filtering updates
342
480
 
343
481
  ## 📈 Recent Progress
344
482
 
345
- ### August 21, 2025 - DevTools Phase 2: Evergreen UI Migration Major Progress 🎨
483
+ ### October 28, 2025 - Phase 7.1 Display Controls Complete 🎨
484
+ - ✅ **Live Preview in Sticky Header** - Real-time log preview updates instantly as controls change
485
+ - ✅ **Timestamp Mode Control** - 4-button group (Absolute, Readable, Relative, Off)
486
+ - ✅ **6 Display Toggles** - Emoji, Component, Level, Message (disabled), JSON Data, Stack Trace
487
+ - ✅ **Bulk Operations** - All On, All Off, Reset buttons for quick control
488
+ - ✅ **Clean Architecture** - Removed all subheadings/dividers, single sticky container
489
+ - ✅ **API Integration** - Full logger.controls integration for display options and timestamp mode
490
+ - 🔧 **Fixed SegmentedControl Issue** - Replaced with button group (not in Evergreen UI v7)
491
+ - 📦 **Component Updates** - DisplayControls.jsx created, PanelContainer/ComponentFilters/GlobalControls simplified
492
+
493
+ ### October 27, 2025 - DevTools UI Enhancement Planning & Architecture 🎛️
494
+ - ✅ **Gap Analysis Complete** - Identified JSG Logger exposes only ~20% of capabilities in current DevTools UI
495
+ - ✅ **Feature Prioritization** - Mapped 7 critical missing feature categories with implementation priorities
496
+ - ✅ **Architecture Planning** - Designed comprehensive UI enhancement covering display controls, component management, log viewer, advanced config, statistics, and UI polish
497
+ - 🎯 **Phase 7 Expansion** - Redefined DevTools development as comprehensive UI enhancement rather than simple panel addition
498
+ - 📋 **Roadmap Updated** - Updated implementation phases to reflect new DevTools focus and priorities
499
+
500
+ ### August 21, 2025 - DevTools Phase 2: Evergreen UI Migration Complete ✅
346
501
  - ✅ **Professional UI Architecture** - Complete Preact + Evergreen UI DevTools application
347
502
  - ✅ **Separate DevTools Package** - Independent development environment in `devtools/` directory
348
503
  - ✅ **Custom Theme System** - Professional dark theme with JSG Logger branding colors
@@ -715,6 +870,8 @@ if (this.loggers.core) {
715
870
  ### **Phase 10: Developer Experience Enhancements** 🎯 FUTURE
716
871
  **Goal**: Make JSG Logger deployment effortless for new projects with zero friction onboarding
717
872
 
873
+ *Note: This phase moved to lower priority as DevTools UI enhancement takes precedence based on gap analysis revealing only 20% of library capabilities currently exposed in UI.*
874
+
718
875
  **Current State Analysis:**
719
876
  - ✅ **Easy to use**: `JSGLogger.getInstance({ configPath: './logger-config.json' })`
720
877
  - ✅ **Auto-discovery**: Missing components created automatically
@@ -105,6 +105,9 @@
105
105
  }
106
106
  }
107
107
  },
108
+ "devtools": {
109
+ "enabled": false
110
+ },
108
111
  "fileOverrides": {
109
112
  "src/api/auth.js": {
110
113
  "level": "trace",
@@ -57,7 +57,7 @@ export const createBrowserFormatter = (componentName, logStore = null) => {
57
57
 
58
58
  // 3. Component name
59
59
  if (displayConfig.component) {
60
- const componentName = component.name.toUpperCase().replace(/([a-z])([A-Z])/g, '$1-$2');
60
+ const componentName = component.name; // Already formatted by configManager
61
61
  logParts.push(`%c[${componentName}]`);
62
62
  logStyles.push(`color: ${component.color}; font-weight: bold;`);
63
63
  }
@@ -3,7 +3,8 @@
3
3
  * Custom formatter with context data display
4
4
  */
5
5
 
6
- import { COMPONENT_SCHEME, LEVEL_SCHEME } from '../config/component-schemes.js';
6
+ import { LEVEL_SCHEME } from '../config/component-schemes.js';
7
+ import { configManager } from '../config/config-manager.js';
7
8
 
8
9
  /**
9
10
  * Format a value for display in context tree
@@ -36,9 +37,9 @@ export const createCLIFormatter = () => {
36
37
  try {
37
38
  const log = JSON.parse(chunk);
38
39
 
39
- // Get component info
40
- const component = COMPONENT_SCHEME[log.name] || COMPONENT_SCHEME['core'];
41
- const componentName = component.name.toUpperCase().replace(/([a-z])([A-Z])/g, '$1-$2');
40
+ // Get component info from configManager (supports custom components)
41
+ const component = configManager.getComponentConfig(log.name);
42
+ const componentName = component.name;
42
43
 
43
44
  // Get level info
44
45
  const level = LEVEL_SCHEME[log.level] || LEVEL_SCHEME[30];
package/index.d.ts ADDED
@@ -0,0 +1,192 @@
1
+ /**
2
+ * TypeScript definitions for @crimsonsunset/jsg-logger
3
+ */
4
+
5
+ export interface LoggerInstance {
6
+ info: (message: string, data?: any) => void;
7
+ debug: (message: string, data?: any) => void;
8
+ warn: (message: string, data?: any) => void;
9
+ error: (message: string, data?: any) => void;
10
+ fatal: (message: string, data?: any) => void;
11
+ trace: (message: string, data?: any) => void;
12
+ [key: string]: any;
13
+ }
14
+
15
+ export interface LoggerComponents {
16
+ /**
17
+ * Component loggers - factory functions that ALWAYS return LoggerInstance
18
+ * Components return no-op logger if not initialized or unavailable
19
+ * Safe to call without null checks: components.reactComponents?.().info(...)
20
+ */
21
+ reactComponents?: () => LoggerInstance;
22
+ astroComponents?: () => LoggerInstance;
23
+ astroBuild?: () => LoggerInstance;
24
+ astroIntegration?: () => LoggerInstance;
25
+ contentProcessing?: () => LoggerInstance;
26
+ textUtils?: () => LoggerInstance;
27
+ dateUtils?: () => LoggerInstance;
28
+ pages?: () => LoggerInstance;
29
+ config?: () => LoggerInstance;
30
+ seo?: () => LoggerInstance;
31
+ performance?: () => LoggerInstance;
32
+ devServer?: () => LoggerInstance;
33
+ webComponents?: () => LoggerInstance;
34
+ core?: () => LoggerInstance;
35
+ api?: () => LoggerInstance;
36
+ ui?: () => LoggerInstance;
37
+ database?: () => LoggerInstance;
38
+ test?: () => LoggerInstance;
39
+ preact?: () => LoggerInstance;
40
+ auth?: () => LoggerInstance;
41
+ analytics?: () => LoggerInstance;
42
+ websocket?: () => LoggerInstance;
43
+ notification?: () => LoggerInstance;
44
+ router?: () => LoggerInstance;
45
+ cache?: () => LoggerInstance;
46
+ /**
47
+ * Dynamic component access - always returns a logger factory
48
+ * The factory function always returns LoggerInstance (no-op if unavailable)
49
+ */
50
+ [key: string]: (() => LoggerInstance) | undefined;
51
+ }
52
+
53
+ export interface JSGLoggerConfig {
54
+ configPath?: string;
55
+ config?: Record<string, any>;
56
+ devtools?: {
57
+ enabled?: boolean;
58
+ };
59
+ [key: string]: any;
60
+ }
61
+
62
+ export interface LoggerControls {
63
+ setLevel?: (component: string, level: string) => void;
64
+ getLevel?: (component: string) => string | undefined;
65
+ listComponents?: () => string[];
66
+ enableDebugMode?: () => void;
67
+ enableTraceMode?: () => void;
68
+ addFileOverride?: (filePath: string, overrideConfig: Record<string, any>) => void;
69
+ removeFileOverride?: (filePath: string) => void;
70
+ listFileOverrides?: () => string[];
71
+ setTimestampMode?: (mode: string) => void;
72
+ getTimestampMode?: () => string;
73
+ getTimestampModes?: () => string[];
74
+ setDisplayOption?: (option: string, enabled: boolean) => void;
75
+ getDisplayConfig?: () => Record<string, boolean>;
76
+ toggleDisplayOption?: (option: string) => void;
77
+ getStats?: () => any;
78
+ subscribe?: (callback: Function) => void;
79
+ clearLogs?: () => void;
80
+ getConfigSummary?: () => any;
81
+ setComponentLevel?: (component: string, level: string) => void;
82
+ getComponentLevel?: (component: string) => string | undefined;
83
+ enableDevPanel?: () => Promise<any>;
84
+ disableDevPanel?: () => boolean;
85
+ refresh?: () => void;
86
+ reset?: () => void;
87
+ [key: string]: any;
88
+ }
89
+
90
+ export interface LoggerConfig {
91
+ environment?: string;
92
+ components?: Record<string, any>;
93
+ summary?: any;
94
+ }
95
+
96
+ export interface LoggerInstanceType {
97
+ /**
98
+ * Direct access to component loggers
99
+ */
100
+ [componentName: string]: LoggerInstance | any;
101
+
102
+ /**
103
+ * Auto-discovery convenience getters (factory functions)
104
+ */
105
+ components?: LoggerComponents;
106
+
107
+ /**
108
+ * Get a specific component logger - always returns a logger instance
109
+ * Returns no-op logger if component unavailable or logger not initialized
110
+ * Always available - never undefined
111
+ */
112
+ getComponent: (componentName: string) => LoggerInstance;
113
+
114
+ /**
115
+ * Create a logger for a specific component
116
+ */
117
+ createLogger?: (componentName: string) => LoggerInstance;
118
+
119
+ /**
120
+ * Configuration and debugging info
121
+ */
122
+ config?: LoggerConfig;
123
+
124
+ /**
125
+ * Configuration manager instance
126
+ */
127
+ configManager?: any;
128
+
129
+ /**
130
+ * Log store instance
131
+ */
132
+ logStore?: any;
133
+
134
+ /**
135
+ * Enhanced runtime controls
136
+ */
137
+ controls?: LoggerControls;
138
+
139
+ /**
140
+ * Get singleton instance (async)
141
+ */
142
+ getInstance?: (config?: JSGLoggerConfig) => Promise<LoggerInstanceType> | LoggerInstanceType;
143
+
144
+ /**
145
+ * Get singleton instance (sync)
146
+ */
147
+ getInstanceSync?: (config?: JSGLoggerConfig) => LoggerInstanceType;
148
+
149
+ /**
150
+ * Static performance logging utility
151
+ */
152
+ logPerformance?: (label: string, startTime: number, component?: string) => Promise<number>;
153
+ }
154
+
155
+ export interface JSGLogger {
156
+ /**
157
+ * Get singleton instance with auto-initialization
158
+ * @param config - Initialization options (only used on first call)
159
+ * @returns Enhanced logger exports with controls API
160
+ *
161
+ * Note: Returns Promise if initialization is needed, sync value if already initialized.
162
+ * Use `await` to handle both cases safely.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * const logger = await JSGLogger.getInstance({ configPath: 'logger-config.json' });
167
+ * logger.components?.reactComponents?.().info('Hello');
168
+ * ```
169
+ */
170
+ getInstance(config?: JSGLoggerConfig): Promise<LoggerInstanceType> | LoggerInstanceType;
171
+
172
+ /**
173
+ * Get singleton instance synchronously (for environments without async support)
174
+ * @param config - Initialization options (only used on first call)
175
+ * @returns Enhanced logger exports with controls API
176
+ */
177
+ getInstanceSync(config?: JSGLoggerConfig): LoggerInstanceType;
178
+
179
+ /**
180
+ * Static performance logging utility
181
+ * @param label - Performance label
182
+ * @param startTime - Start time from performance.now()
183
+ * @param component - Optional component name (defaults to 'performance')
184
+ * @returns Duration in milliseconds
185
+ */
186
+ logPerformance(label: string, startTime: number, component?: string): Promise<number>;
187
+ }
188
+
189
+ declare const JSGLogger: JSGLogger;
190
+ export default JSGLogger;
191
+ export { JSGLogger };
192
+