@crimsonsunset/jsg-logger 1.1.7 โ 1.4.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/CHANGELOG.md +47 -0
- package/README.md +20 -16
- package/config/component-schemes.js +13 -10
- package/config/config-manager.js +1 -1
- package/config/default-config.json +1 -55
- package/docs/devtools-roadmap.md +337 -0
- package/docs/next-session.md +110 -127
- package/docs/roadmap.md +91 -27
- package/examples/advanced-config.json +68 -78
- package/formatters/cli-formatter.js +1 -1
- package/index.js +60 -20
- package/package.json +17 -3
|
@@ -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
|
@@ -20,6 +20,7 @@ import {LogStore} from './stores/log-store.js';
|
|
|
20
20
|
class JSGLogger {
|
|
21
21
|
// Static singleton instance
|
|
22
22
|
static _instance = null;
|
|
23
|
+
static _enhancedLoggers = null;
|
|
23
24
|
|
|
24
25
|
constructor() {
|
|
25
26
|
this.loggers = {};
|
|
@@ -32,27 +33,27 @@ class JSGLogger {
|
|
|
32
33
|
/**
|
|
33
34
|
* Get singleton instance with auto-initialization
|
|
34
35
|
* @param {Object} options - Initialization options (only used on first call)
|
|
35
|
-
* @returns {Promise<
|
|
36
|
+
* @returns {Promise<Object>} Enhanced logger exports with controls API
|
|
36
37
|
*/
|
|
37
38
|
static async getInstance(options = {}) {
|
|
38
39
|
if (!JSGLogger._instance) {
|
|
39
40
|
JSGLogger._instance = new JSGLogger();
|
|
40
|
-
await JSGLogger._instance.init(options);
|
|
41
|
+
JSGLogger._enhancedLoggers = await JSGLogger._instance.init(options);
|
|
41
42
|
}
|
|
42
|
-
return JSGLogger.
|
|
43
|
+
return JSGLogger._enhancedLoggers;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Get singleton instance synchronously (for environments without async support)
|
|
47
48
|
* @param {Object} options - Initialization options (only used on first call)
|
|
48
|
-
* @returns {
|
|
49
|
+
* @returns {Object} Enhanced logger exports with controls API
|
|
49
50
|
*/
|
|
50
51
|
static getInstanceSync(options = {}) {
|
|
51
52
|
if (!JSGLogger._instance) {
|
|
52
53
|
JSGLogger._instance = new JSGLogger();
|
|
53
|
-
JSGLogger._instance.initSync(options);
|
|
54
|
+
JSGLogger._enhancedLoggers = JSGLogger._instance.initSync(options);
|
|
54
55
|
}
|
|
55
|
-
return JSGLogger.
|
|
56
|
+
return JSGLogger._enhancedLoggers;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -86,8 +87,8 @@ class JSGLogger {
|
|
|
86
87
|
this.initialized = true;
|
|
87
88
|
|
|
88
89
|
// Log initialization success
|
|
89
|
-
if (this.loggers.
|
|
90
|
-
this.loggers.
|
|
90
|
+
if (this.loggers.core) {
|
|
91
|
+
this.loggers.core.info('JSG Logger initialized', {
|
|
91
92
|
environment: this.environment,
|
|
92
93
|
components: components.length,
|
|
93
94
|
projectName: configManager.getProjectName(),
|
|
@@ -129,8 +130,8 @@ class JSGLogger {
|
|
|
129
130
|
this.initialized = true;
|
|
130
131
|
|
|
131
132
|
// Log initialization success
|
|
132
|
-
if (this.loggers.
|
|
133
|
-
this.loggers.
|
|
133
|
+
if (this.loggers.core) {
|
|
134
|
+
this.loggers.core.info('JSG Logger initialized (sync)', {
|
|
134
135
|
environment: this.environment,
|
|
135
136
|
components: components.length,
|
|
136
137
|
projectName: configManager.getProjectName(),
|
|
@@ -184,13 +185,17 @@ class JSGLogger {
|
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
/**
|
|
187
|
-
* Create
|
|
188
|
+
* Create component aliases (for camelCase/kebab-case compatibility)
|
|
188
189
|
* @private
|
|
189
190
|
*/
|
|
190
191
|
createAliases() {
|
|
191
|
-
//
|
|
192
|
-
this.loggers.
|
|
193
|
-
|
|
192
|
+
// Auto-generate camelCase aliases for kebab-case component names
|
|
193
|
+
Object.keys(this.loggers).forEach(componentName => {
|
|
194
|
+
if (componentName.includes('-')) {
|
|
195
|
+
const camelCase = componentName.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
196
|
+
this.loggers[camelCase] = this.loggers[componentName];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
194
199
|
}
|
|
195
200
|
|
|
196
201
|
/**
|
|
@@ -333,6 +338,44 @@ class JSGLogger {
|
|
|
333
338
|
return configManager.config.components?.[component]?.level;
|
|
334
339
|
},
|
|
335
340
|
|
|
341
|
+
// DevTools panel controls
|
|
342
|
+
enableDevPanel: async () => {
|
|
343
|
+
if (typeof window === 'undefined') {
|
|
344
|
+
console.warn('[JSG-LOGGER] DevTools panel only available in browser environments');
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
try {
|
|
349
|
+
// In development: import source files directly for hot reload
|
|
350
|
+
// In production: import built bundle
|
|
351
|
+
const isDev = import.meta.env?.DEV || window.location.hostname === 'localhost';
|
|
352
|
+
|
|
353
|
+
let module;
|
|
354
|
+
if (isDev) {
|
|
355
|
+
console.log('๐ฅ DEV MODE: Attempting to load DevTools from SOURCE for hot reload');
|
|
356
|
+
try {
|
|
357
|
+
// Fix the import path for Vite dev server
|
|
358
|
+
const importPath = '/src/panel-entry.jsx';
|
|
359
|
+
console.log('๐ Importing:', importPath);
|
|
360
|
+
module = await import(importPath);
|
|
361
|
+
console.log('โ
Source import successful:', module);
|
|
362
|
+
} catch (sourceError) {
|
|
363
|
+
console.error('โ Source import failed, falling back to bundle:', sourceError);
|
|
364
|
+
const cacheBuster = Date.now();
|
|
365
|
+
module = await import(`./devtools/dist/panel-entry.js?v=${cacheBuster}`);
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
console.log('๐ฆ PROD MODE: Loading DevTools from built bundle');
|
|
369
|
+
const cacheBuster = Date.now();
|
|
370
|
+
module = await import(`./devtools/dist/panel-entry.js?v=${cacheBuster}`);
|
|
371
|
+
}
|
|
372
|
+
return module.initializePanel();
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error('[JSG-LOGGER] Failed to load DevTools panel:', error);
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
|
|
336
379
|
// System controls
|
|
337
380
|
refresh: () => this.refreshLoggers(),
|
|
338
381
|
reset: () => {
|
|
@@ -428,7 +471,7 @@ class JSGLogger {
|
|
|
428
471
|
};
|
|
429
472
|
|
|
430
473
|
return {
|
|
431
|
-
|
|
474
|
+
core: fallback,
|
|
432
475
|
createLogger: () => fallback,
|
|
433
476
|
config: {environment: 'fallback'},
|
|
434
477
|
logStore: {getRecent: () => [], clear: () => {}},
|
|
@@ -536,12 +579,9 @@ class JSGLogger {
|
|
|
536
579
|
}
|
|
537
580
|
}
|
|
538
581
|
|
|
539
|
-
// Create singleton instance
|
|
540
|
-
const logger = new JSGLogger();
|
|
541
|
-
|
|
542
582
|
// Initialize synchronously with default config for immediate use
|
|
543
583
|
// (Chrome extensions and other environments that don't support top-level await)
|
|
544
|
-
const enhancedLoggers =
|
|
584
|
+
const enhancedLoggers = JSGLogger.getInstanceSync();
|
|
545
585
|
|
|
546
586
|
// Make runtime controls available globally in browser for debugging
|
|
547
587
|
if (isBrowser() && typeof window !== 'undefined') {
|
|
@@ -556,4 +596,4 @@ enhancedLoggers.JSGLogger = JSGLogger;
|
|
|
556
596
|
|
|
557
597
|
// Export both the initialized loggers and the class for advanced usage
|
|
558
598
|
export default enhancedLoggers;
|
|
559
|
-
export {
|
|
599
|
+
export {JSGLogger};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crimsonsunset/jsg-logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "JSG Logger - Multi-environment logger with smart detection, file-level overrides, and beautiful console formatting",
|
|
6
6
|
"main": "index.js",
|
|
@@ -27,10 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/crimsonsunset/jsg-logger#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
30
|
+
"@preact/preset-vite": "^2.10.2",
|
|
31
|
+
"evergreen-ui": "^7.1.9",
|
|
32
|
+
"lodash.merge": "^4.6.2",
|
|
33
|
+
"pino": "^9.7.0",
|
|
34
|
+
"preact": "^10.27.1"
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
|
-
"pino-colada": "^2.2.2"
|
|
37
|
+
"pino-colada": "^2.2.2",
|
|
38
|
+
"vite": "^5.1.3"
|
|
34
39
|
},
|
|
35
40
|
"peerDependencies": {
|
|
36
41
|
"pino-colada": "^2.2.2"
|
|
@@ -64,11 +69,20 @@
|
|
|
64
69
|
"./examples/*": "./examples/*"
|
|
65
70
|
},
|
|
66
71
|
"scripts": {
|
|
72
|
+
"dev": "vite",
|
|
73
|
+
"dev:devtools": "vite",
|
|
74
|
+
"test:devtools": "vite",
|
|
75
|
+
"build:devtools": "cd devtools && npm run build",
|
|
67
76
|
"release:patch": "npm version patch && npm publish --access public",
|
|
68
77
|
"release:minor": "npm version minor && npm publish --access public",
|
|
69
78
|
"release:major": "npm version major && npm publish --access public",
|
|
70
79
|
"release": "npm run release:patch",
|
|
71
80
|
"publish:public": "npm publish --access public",
|
|
81
|
+
"publish:github": "npm publish --registry=https://npm.pkg.github.com/ --access public",
|
|
82
|
+
"publish:dual": "npm publish --access public && npm publish --registry=https://npm.pkg.github.com/ --access public",
|
|
83
|
+
"release:dual:patch": "npm version patch && npm run publish:dual",
|
|
84
|
+
"release:dual:minor": "npm version minor && npm run publish:dual",
|
|
85
|
+
"release:dual:major": "npm version major && npm run publish:dual",
|
|
72
86
|
"check": "npm run test && echo 'Package ready for publishing'"
|
|
73
87
|
}
|
|
74
88
|
}
|