@crimsonsunset/jsg-logger 1.1.7 โ 1.2.0
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/config/component-schemes.js +1 -10
- package/config/config-manager.js +1 -1
- package/config/default-config.json +1 -55
- package/docs/roadmap.md +18 -22
- package/examples/advanced-config.json +68 -78
- package/formatters/cli-formatter.js +1 -1
- package/index.js +13 -9
- package/package.json +1 -1
|
@@ -4,16 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export const COMPONENT_SCHEME = {
|
|
7
|
-
'
|
|
8
|
-
'soundcloud': { emoji: '๐ต', color: '#FF5500', name: 'SoundCloud' },
|
|
9
|
-
'youtube': { emoji: '๐น', color: '#FF0000', name: 'YouTube' },
|
|
10
|
-
'site-detector': { emoji: '๐', color: '#00C896', name: 'SiteDetector' },
|
|
11
|
-
'websocket': { emoji: '๐', color: '#9B59B6', name: 'WebSocket' },
|
|
12
|
-
'popup': { emoji: '๐๏ธ', color: '#FF6B6B', name: 'Popup' },
|
|
13
|
-
'background': { emoji: '๐ง', color: '#4ECDC4', name: 'Background' },
|
|
14
|
-
'priority-manager': { emoji: 'โ๏ธ', color: '#45B7D1', name: 'PriorityManager' },
|
|
15
|
-
'settings': { emoji: 'โ๏ธ', color: '#96CEB4', name: 'Settings' },
|
|
16
|
-
'test': { emoji: '๐งช', color: '#FFEAA7', name: 'Test' }
|
|
7
|
+
'core': { emoji: '๐ฏ', color: '#8E44AD', name: 'JSG-CORE' }
|
|
17
8
|
};
|
|
18
9
|
|
|
19
10
|
export const LEVEL_SCHEME = {
|
package/config/config-manager.js
CHANGED
|
@@ -406,7 +406,7 @@ export class ConfigManager {
|
|
|
406
406
|
* @returns {Object} Component configuration
|
|
407
407
|
*/
|
|
408
408
|
getComponentConfig(componentName, filePath = null) {
|
|
409
|
-
const baseComponent = this.config.components?.[componentName] || COMPONENT_SCHEME[componentName] || COMPONENT_SCHEME['
|
|
409
|
+
const baseComponent = this.config.components?.[componentName] || COMPONENT_SCHEME[componentName] || COMPONENT_SCHEME['core'];
|
|
410
410
|
|
|
411
411
|
// Check for file-specific overrides
|
|
412
412
|
const checkFile = filePath || this.currentFile;
|
|
@@ -26,65 +26,11 @@
|
|
|
26
26
|
"60": { "name": "FATAL", "emoji": "๐", "color": "#D63031" }
|
|
27
27
|
},
|
|
28
28
|
"components": {
|
|
29
|
-
"
|
|
29
|
+
"core": {
|
|
30
30
|
"emoji": "๐ฏ",
|
|
31
31
|
"color": "#4A90E2",
|
|
32
32
|
"name": "JSG-CORE",
|
|
33
33
|
"level": "info"
|
|
34
|
-
},
|
|
35
|
-
"soundcloud": {
|
|
36
|
-
"emoji": "๐ต",
|
|
37
|
-
"color": "#FF5500",
|
|
38
|
-
"name": "SoundCloud",
|
|
39
|
-
"level": "info"
|
|
40
|
-
},
|
|
41
|
-
"youtube": {
|
|
42
|
-
"emoji": "๐น",
|
|
43
|
-
"color": "#FF0000",
|
|
44
|
-
"name": "YouTube",
|
|
45
|
-
"level": "info"
|
|
46
|
-
},
|
|
47
|
-
"site-detector": {
|
|
48
|
-
"emoji": "๐",
|
|
49
|
-
"color": "#00C896",
|
|
50
|
-
"name": "SiteDetector",
|
|
51
|
-
"level": "info"
|
|
52
|
-
},
|
|
53
|
-
"websocket": {
|
|
54
|
-
"emoji": "๐",
|
|
55
|
-
"color": "#9B59B6",
|
|
56
|
-
"name": "WebSocket",
|
|
57
|
-
"level": "info"
|
|
58
|
-
},
|
|
59
|
-
"popup": {
|
|
60
|
-
"emoji": "๐๏ธ",
|
|
61
|
-
"color": "#FF6B6B",
|
|
62
|
-
"name": "Popup",
|
|
63
|
-
"level": "info"
|
|
64
|
-
},
|
|
65
|
-
"background": {
|
|
66
|
-
"emoji": "๐ง",
|
|
67
|
-
"color": "#4ECDC4",
|
|
68
|
-
"name": "Background",
|
|
69
|
-
"level": "info"
|
|
70
|
-
},
|
|
71
|
-
"priority-manager": {
|
|
72
|
-
"emoji": "โ๏ธ",
|
|
73
|
-
"color": "#45B7D1",
|
|
74
|
-
"name": "PriorityManager",
|
|
75
|
-
"level": "info"
|
|
76
|
-
},
|
|
77
|
-
"settings": {
|
|
78
|
-
"emoji": "โ๏ธ",
|
|
79
|
-
"color": "#96CEB4",
|
|
80
|
-
"name": "Settings",
|
|
81
|
-
"level": "info"
|
|
82
|
-
},
|
|
83
|
-
"test": {
|
|
84
|
-
"emoji": "๐งช",
|
|
85
|
-
"color": "#FFEAA7",
|
|
86
|
-
"name": "Test",
|
|
87
|
-
"level": "debug"
|
|
88
34
|
}
|
|
89
35
|
},
|
|
90
36
|
"fileOverrides": {
|
package/docs/roadmap.md
CHANGED
|
@@ -348,7 +348,7 @@ Console filtering updates
|
|
|
348
348
|
2. Default config with 10 hardcoded legacy components
|
|
349
349
|
3. Component schemes duplication
|
|
350
350
|
4. Hardcoded legacy aliases for legacy components
|
|
351
|
-
5. Core component dependency on '
|
|
351
|
+
5. โ
Core component dependency on 'core' logger
|
|
352
352
|
6. Config loading path resolution issues
|
|
353
353
|
- ๐ฏ **Phase 9 Planned**: Complete roadmap for making logger truly generic
|
|
354
354
|
- โ
**Testing Successful**: JSG Logger v1.1.0 API features work, but components wrong
|
|
@@ -583,7 +583,7 @@ During Phase 8 integration testing with jsg-tech-check-site, we discovered the l
|
|
|
583
583
|
|
|
584
584
|
**Observable Issues:**
|
|
585
585
|
```
|
|
586
|
-
[JSG-LOGGER] Component 'astro-build' not found. Available:
|
|
586
|
+
[JSG-LOGGER] Component 'astro-build' not found. Available: core
|
|
587
587
|
```
|
|
588
588
|
|
|
589
589
|
Despite providing a proper `logger-config.json` with Astro-specific components, the logger falls back to legacy defaults instead of loading the project's configuration.
|
|
@@ -599,17 +599,8 @@ Despite providing a proper `logger-config.json` with Astro-specific components,
|
|
|
599
599
|
##### **2. Default Configuration Hardcoding**
|
|
600
600
|
**File:** `/config/default-config.json`
|
|
601
601
|
- **Hardcoded project name**: โ
`"JSG Logger"`
|
|
602
|
-
- **
|
|
603
|
-
|
|
604
|
-
- `soundcloud` (๐ต SoundCloud)
|
|
605
|
-
- `youtube` (๐น YouTube)
|
|
606
|
-
- `site-detector` (๐ SiteDetector)
|
|
607
|
-
- `websocket` (๐ WebSocket)
|
|
608
|
-
- `popup` (๐๏ธ Popup)
|
|
609
|
-
- `background` (๐ง Background)
|
|
610
|
-
- `priority-manager` (โ๏ธ PriorityManager)
|
|
611
|
-
- `settings` (โ๏ธ Settings)
|
|
612
|
-
- `test` (๐งช Test)
|
|
602
|
+
- โ
**Minimal generic components**: Only `core` component by default
|
|
603
|
+
- โ
**Projects define their own**: Components specified in project config files
|
|
613
604
|
|
|
614
605
|
##### **3. Component Schemes Duplication**
|
|
615
606
|
**File:** `/config/component-schemes.js`
|
|
@@ -619,15 +610,20 @@ Despite providing a proper `logger-config.json` with Astro-specific components,
|
|
|
619
610
|
##### **4. Hardcoded Legacy Aliases**
|
|
620
611
|
```javascript
|
|
621
612
|
// In createAliases() method:
|
|
622
|
-
|
|
623
|
-
this.loggers.
|
|
613
|
+
// Auto-generate camelCase aliases for kebab-case components
|
|
614
|
+
Object.keys(this.loggers).forEach(componentName => {
|
|
615
|
+
if (componentName.includes('-')) {
|
|
616
|
+
const camelCase = componentName.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
617
|
+
this.loggers[camelCase] = this.loggers[componentName];
|
|
618
|
+
}
|
|
619
|
+
});
|
|
624
620
|
```
|
|
625
621
|
|
|
626
622
|
##### **5. Core Component Dependency**
|
|
627
623
|
```javascript
|
|
628
|
-
// Initialization
|
|
629
|
-
if (this.loggers.
|
|
630
|
-
this.loggers.
|
|
624
|
+
// Initialization uses 'core' component:
|
|
625
|
+
if (this.loggers.core) {
|
|
626
|
+
this.loggers.core.info('JSG Logger initialized', {...});
|
|
631
627
|
}
|
|
632
628
|
```
|
|
633
629
|
|
|
@@ -657,7 +653,7 @@ if (this.loggers.cacp) {
|
|
|
657
653
|
|
|
658
654
|
##### **Fix 2: Rename Core Class**
|
|
659
655
|
**Target**: `/index.js`
|
|
660
|
-
- `
|
|
656
|
+
- โ
`JSGLogger` class renamed
|
|
661
657
|
- Update all static method references
|
|
662
658
|
- Update error messages
|
|
663
659
|
- โ
Update browser global: `window.JSG_Logger`
|
|
@@ -670,12 +666,12 @@ if (this.loggers.cacp) {
|
|
|
670
666
|
|
|
671
667
|
##### **Fix 4: Remove Legacy-Specific Logic**
|
|
672
668
|
**Target**: `/index.js` `createAliases()` method
|
|
673
|
-
- Remove hardcoded legacy aliases
|
|
669
|
+
- โ
Remove hardcoded legacy aliases, use generic camelCase generation
|
|
674
670
|
- Make aliases configurable if needed, not hardcoded
|
|
675
671
|
|
|
676
672
|
##### **Fix 5: Use Configurable Core Component**
|
|
677
673
|
**Target**: Initialization logging
|
|
678
|
-
- Replace `this.loggers.
|
|
674
|
+
- โ
Replace `this.loggers.core.info()` with generic core component
|
|
679
675
|
- Use `this.loggers.core` or first available component
|
|
680
676
|
- Graceful fallback if no components configured
|
|
681
677
|
|
|
@@ -695,7 +691,7 @@ if (this.loggers.cacp) {
|
|
|
695
691
|
#### **๐ Implementation Steps**
|
|
696
692
|
1. **Debug config loading** - Fix why `logger-config.json` is ignored
|
|
697
693
|
2. โ
**Rename core class** - `JSGLogger` completed
|
|
698
|
-
3. **Replace default config** -
|
|
694
|
+
3. โ
**Replace default config** - Minimal generic with only 'core' component
|
|
699
695
|
4. **Remove hardcoded aliases** - Make legacy aliases configurable
|
|
700
696
|
5. **Fix core component** - Use configurable core for init logging
|
|
701
697
|
6. **Update browser global** - `window.JSG_Logger`
|
|
@@ -11,141 +11,131 @@
|
|
|
11
11
|
"timestamp": true,
|
|
12
12
|
"emoji": true,
|
|
13
13
|
"component": true,
|
|
14
|
-
"level":
|
|
14
|
+
"level": true,
|
|
15
15
|
"message": true,
|
|
16
16
|
"jsonPayload": true,
|
|
17
17
|
"stackTrace": true
|
|
18
18
|
},
|
|
19
19
|
"components": {
|
|
20
|
-
"
|
|
20
|
+
"core": {
|
|
21
21
|
"emoji": "๐ฏ",
|
|
22
22
|
"color": "#4A90E2",
|
|
23
23
|
"name": "JSG-CORE",
|
|
24
24
|
"level": "debug"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
27
|
-
"emoji": "
|
|
26
|
+
"api": {
|
|
27
|
+
"emoji": "๐",
|
|
28
28
|
"color": "#FF5500",
|
|
29
|
-
"name": "
|
|
29
|
+
"name": "API",
|
|
30
30
|
"level": "trace"
|
|
31
31
|
},
|
|
32
|
-
"
|
|
33
|
-
"emoji": "
|
|
32
|
+
"database": {
|
|
33
|
+
"emoji": "๐พ",
|
|
34
34
|
"color": "#FF0000",
|
|
35
|
-
"name": "
|
|
35
|
+
"name": "Database",
|
|
36
36
|
"level": "info"
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
"emoji": "
|
|
38
|
+
"auth": {
|
|
39
|
+
"emoji": "๐",
|
|
40
40
|
"color": "#00C896",
|
|
41
|
-
"name": "
|
|
41
|
+
"name": "Auth",
|
|
42
42
|
"level": "debug"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
"emoji": "
|
|
44
|
+
"utils": {
|
|
45
|
+
"emoji": "๐ ๏ธ",
|
|
46
46
|
"color": "#9B59B6",
|
|
47
|
-
"name": "
|
|
47
|
+
"name": "Utils",
|
|
48
48
|
"level": "warn"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
51
|
-
"emoji": "
|
|
50
|
+
"ui": {
|
|
51
|
+
"emoji": "๐จ",
|
|
52
52
|
"color": "#FF6B6B",
|
|
53
|
-
"name": "
|
|
54
|
-
"level": "debug"
|
|
55
|
-
},
|
|
56
|
-
"background": {
|
|
57
|
-
"emoji": "๐ง",
|
|
58
|
-
"color": "#4ECDC4",
|
|
59
|
-
"name": "Background",
|
|
53
|
+
"name": "UI",
|
|
60
54
|
"level": "info"
|
|
61
55
|
},
|
|
62
|
-
"
|
|
63
|
-
"emoji": "โ๏ธ",
|
|
64
|
-
"color": "#45B7D1",
|
|
65
|
-
"name": "PriorityManager",
|
|
66
|
-
"level": "warn"
|
|
67
|
-
},
|
|
68
|
-
"settings": {
|
|
56
|
+
"service": {
|
|
69
57
|
"emoji": "โ๏ธ",
|
|
70
|
-
"color": "#
|
|
71
|
-
"name": "
|
|
72
|
-
"level": "
|
|
58
|
+
"color": "#4ECDC4",
|
|
59
|
+
"name": "Service",
|
|
60
|
+
"level": "error"
|
|
73
61
|
},
|
|
74
62
|
"test": {
|
|
75
63
|
"emoji": "๐งช",
|
|
76
64
|
"color": "#FFEAA7",
|
|
77
65
|
"name": "Test",
|
|
78
|
-
"level": "
|
|
66
|
+
"level": "debug"
|
|
79
67
|
}
|
|
80
68
|
},
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"component": "soundcloud",
|
|
85
|
-
"emoji": "๐ต",
|
|
69
|
+
"environments": {
|
|
70
|
+
"development": {
|
|
71
|
+
"globalLevel": "debug",
|
|
86
72
|
"display": {
|
|
87
|
-
"timestamp": true,
|
|
88
|
-
"emoji": true,
|
|
89
|
-
"component": true,
|
|
90
73
|
"level": true,
|
|
91
|
-
"
|
|
92
|
-
"jsonPayload": true,
|
|
74
|
+
"timestamp": true,
|
|
93
75
|
"stackTrace": true
|
|
76
|
+
},
|
|
77
|
+
"components": {
|
|
78
|
+
"api": "trace",
|
|
79
|
+
"database": "debug",
|
|
80
|
+
"auth": "trace"
|
|
94
81
|
}
|
|
95
82
|
},
|
|
96
|
-
"
|
|
97
|
-
"
|
|
83
|
+
"test": {
|
|
84
|
+
"globalLevel": "warn",
|
|
98
85
|
"display": {
|
|
99
|
-
"
|
|
86
|
+
"emoji": false,
|
|
87
|
+
"timestamp": false
|
|
88
|
+
},
|
|
89
|
+
"components": {
|
|
90
|
+
"test": "trace",
|
|
91
|
+
"api": "debug"
|
|
100
92
|
}
|
|
101
93
|
},
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"emoji": "๐๏ธ",
|
|
105
|
-
"timestampMode": "relative",
|
|
94
|
+
"production": {
|
|
95
|
+
"globalLevel": "error",
|
|
106
96
|
"display": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"
|
|
97
|
+
"emoji": false,
|
|
98
|
+
"component": false,
|
|
99
|
+
"stackTrace": false
|
|
100
|
+
},
|
|
101
|
+
"components": {
|
|
102
|
+
"core": "warn",
|
|
103
|
+
"auth": "info",
|
|
104
|
+
"api": "warn"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"fileOverrides": {
|
|
109
|
+
"src/api/auth.js": {
|
|
110
|
+
"level": "trace",
|
|
111
|
+
"component": "auth",
|
|
112
|
+
"description": "Debug auth endpoints",
|
|
113
|
+
"display": {
|
|
114
|
+
"jsonPayload": true,
|
|
113
115
|
"stackTrace": true
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
|
-
"src/
|
|
118
|
+
"src/database/*.js": {
|
|
119
|
+
"level": "debug",
|
|
120
|
+
"component": "database",
|
|
121
|
+
"description": "Database operations debugging"
|
|
122
|
+
},
|
|
123
|
+
"src/ui/components/**": {
|
|
117
124
|
"level": "info",
|
|
125
|
+
"component": "ui",
|
|
126
|
+
"description": "UI component lifecycle",
|
|
118
127
|
"display": {
|
|
119
128
|
"jsonPayload": false,
|
|
120
129
|
"stackTrace": false
|
|
121
130
|
}
|
|
122
131
|
},
|
|
123
|
-
"src/
|
|
132
|
+
"src/core.js": {
|
|
124
133
|
"level": "debug",
|
|
125
134
|
"emoji": "๐ฏ",
|
|
126
135
|
"display": {
|
|
127
136
|
"level": true,
|
|
128
137
|
"jsonPayload": true
|
|
129
138
|
}
|
|
130
|
-
},
|
|
131
|
-
"src/sites/youtube.js": {
|
|
132
|
-
"level": "info",
|
|
133
|
-
"emoji": "๐น",
|
|
134
|
-
"timestampMode": "readable",
|
|
135
|
-
"display": {
|
|
136
|
-
"timestamp": true,
|
|
137
|
-
"jsonPayload": false
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
"src/test-*.js": {
|
|
141
|
-
"level": "trace",
|
|
142
|
-
"emoji": "๐งช",
|
|
143
|
-
"timestampMode": "disable",
|
|
144
|
-
"display": {
|
|
145
|
-
"timestamp": false,
|
|
146
|
-
"level": true,
|
|
147
|
-
"jsonPayload": true
|
|
148
|
-
}
|
|
149
139
|
}
|
|
150
140
|
}
|
|
151
141
|
}
|
|
@@ -25,7 +25,7 @@ export const createCLIFormatter = () => {
|
|
|
25
25
|
const log = JSON.parse(chunk);
|
|
26
26
|
|
|
27
27
|
// Get component info
|
|
28
|
-
const component = COMPONENT_SCHEME[log.name] || COMPONENT_SCHEME['
|
|
28
|
+
const component = COMPONENT_SCHEME[log.name] || COMPONENT_SCHEME['core'];
|
|
29
29
|
const componentName = component.name.toUpperCase().replace(/([a-z])([A-Z])/g, '$1-$2');
|
|
30
30
|
|
|
31
31
|
// Get level info
|
package/index.js
CHANGED
|
@@ -86,8 +86,8 @@ class JSGLogger {
|
|
|
86
86
|
this.initialized = true;
|
|
87
87
|
|
|
88
88
|
// Log initialization success
|
|
89
|
-
if (this.loggers.
|
|
90
|
-
this.loggers.
|
|
89
|
+
if (this.loggers.core) {
|
|
90
|
+
this.loggers.core.info('JSG Logger initialized', {
|
|
91
91
|
environment: this.environment,
|
|
92
92
|
components: components.length,
|
|
93
93
|
projectName: configManager.getProjectName(),
|
|
@@ -129,8 +129,8 @@ class JSGLogger {
|
|
|
129
129
|
this.initialized = true;
|
|
130
130
|
|
|
131
131
|
// Log initialization success
|
|
132
|
-
if (this.loggers.
|
|
133
|
-
this.loggers.
|
|
132
|
+
if (this.loggers.core) {
|
|
133
|
+
this.loggers.core.info('JSG Logger initialized (sync)', {
|
|
134
134
|
environment: this.environment,
|
|
135
135
|
components: components.length,
|
|
136
136
|
projectName: configManager.getProjectName(),
|
|
@@ -184,13 +184,17 @@ class JSGLogger {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
* Create
|
|
187
|
+
* Create component aliases (for camelCase/kebab-case compatibility)
|
|
188
188
|
* @private
|
|
189
189
|
*/
|
|
190
190
|
createAliases() {
|
|
191
|
-
//
|
|
192
|
-
this.loggers.
|
|
193
|
-
|
|
191
|
+
// Auto-generate camelCase aliases for kebab-case component names
|
|
192
|
+
Object.keys(this.loggers).forEach(componentName => {
|
|
193
|
+
if (componentName.includes('-')) {
|
|
194
|
+
const camelCase = componentName.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
195
|
+
this.loggers[camelCase] = this.loggers[componentName];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
/**
|
|
@@ -428,7 +432,7 @@ class JSGLogger {
|
|
|
428
432
|
};
|
|
429
433
|
|
|
430
434
|
return {
|
|
431
|
-
|
|
435
|
+
core: fallback,
|
|
432
436
|
createLogger: () => fallback,
|
|
433
437
|
config: {environment: 'fallback'},
|
|
434
438
|
logStore: {getRecent: () => [], clear: () => {}},
|
package/package.json
CHANGED