@crimsonsunset/jsg-logger 1.1.3 → 1.1.5
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/README.md +5 -5
- package/config/component-schemes.js +2 -2
- package/config/config-manager.js +2 -2
- package/config/default-config.json +1 -1
- package/docs/roadmap.md +1 -0
- package/examples/advanced-config.json +1 -1
- package/formatters/browser-formatter.js +1 -1
- package/formatters/cli-formatter.js +1 -1
- package/formatters/server-formatter.js +1 -1
- package/index.js +23 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -442,11 +442,11 @@ logger.controls.addFileOverride('src/popup.js', { // Debug popup
|
|
|
442
442
|
In browser environments, runtime controls are available globally:
|
|
443
443
|
|
|
444
444
|
```javascript
|
|
445
|
-
// Available as window.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
445
|
+
// Available as window.JSG_Logger
|
|
446
|
+
JSG_Logger.enableDebugMode();
|
|
447
|
+
JSG_Logger.setDisplayOption('level', true);
|
|
448
|
+
JSG_Logger.addFileOverride('src/popup.js', { level: 'trace' });
|
|
449
|
+
JSG_Logger.getStats();
|
|
450
450
|
```
|
|
451
451
|
|
|
452
452
|
## ⚠️ **Disclaimer**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component and Level Schemes for
|
|
2
|
+
* Component and Level Schemes for JSG Logger
|
|
3
3
|
* Defines visual styling and organization for all logger components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export const COMPONENT_SCHEME = {
|
|
7
|
-
'cacp': { emoji: '🎯', color: '#8E44AD', name: '
|
|
7
|
+
'cacp': { emoji: '🎯', color: '#8E44AD', name: 'JSG-CORE' },
|
|
8
8
|
'soundcloud': { emoji: '🎵', color: '#FF5500', name: 'SoundCloud' },
|
|
9
9
|
'youtube': { emoji: '📹', color: '#FF0000', name: 'YouTube' },
|
|
10
10
|
'site-detector': { emoji: '🔍', color: '#00C896', name: 'SiteDetector' },
|
package/config/config-manager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configuration Manager for
|
|
2
|
+
* Configuration Manager for JSG Logger
|
|
3
3
|
* Handles loading, merging, and validation of logger configurations
|
|
4
4
|
* Implements smart level resolution and file override system
|
|
5
5
|
*/
|
|
@@ -494,7 +494,7 @@ export class ConfigManager {
|
|
|
494
494
|
* @returns {string} Project name
|
|
495
495
|
*/
|
|
496
496
|
getProjectName() {
|
|
497
|
-
return this.config.projectName || '
|
|
497
|
+
return this.config.projectName || 'JSG Logger';
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
/**
|
package/docs/roadmap.md
CHANGED
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
- [ ] **Performance Monitoring** - Log performance metrics
|
|
116
116
|
- [ ] **Export Utilities** - Save logs to file formats
|
|
117
117
|
- [ ] **Integration Guides** - Framework-specific examples
|
|
118
|
+
- [ ] **Restore pino-pretty Support** - Add back full pino-pretty formatter with proper browser/Node.js environment detection to avoid bundling conflicts
|
|
118
119
|
|
|
119
120
|
---
|
|
120
121
|
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {LogStore} from './stores/log-store.js';
|
|
|
17
17
|
* Main Logger Class
|
|
18
18
|
* Manages logger instances and provides the public API
|
|
19
19
|
*/
|
|
20
|
-
class
|
|
20
|
+
class JSGLogger {
|
|
21
21
|
// Static singleton instance
|
|
22
22
|
static _instance = null;
|
|
23
23
|
|
|
@@ -32,27 +32,27 @@ class CACPLogger {
|
|
|
32
32
|
/**
|
|
33
33
|
* Get singleton instance with auto-initialization
|
|
34
34
|
* @param {Object} options - Initialization options (only used on first call)
|
|
35
|
-
* @returns {Promise<
|
|
35
|
+
* @returns {Promise<JSGLogger>} Singleton logger instance
|
|
36
36
|
*/
|
|
37
37
|
static async getInstance(options = {}) {
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
await
|
|
38
|
+
if (!JSGLogger._instance) {
|
|
39
|
+
JSGLogger._instance = new JSGLogger();
|
|
40
|
+
await JSGLogger._instance.init(options);
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return JSGLogger._instance;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Get singleton instance synchronously (for environments without async support)
|
|
47
47
|
* @param {Object} options - Initialization options (only used on first call)
|
|
48
|
-
* @returns {
|
|
48
|
+
* @returns {JSGLogger} Singleton logger instance
|
|
49
49
|
*/
|
|
50
50
|
static getInstanceSync(options = {}) {
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
if (!JSGLogger._instance) {
|
|
52
|
+
JSGLogger._instance = new JSGLogger();
|
|
53
|
+
JSGLogger._instance.initSync(options);
|
|
54
54
|
}
|
|
55
|
-
return
|
|
55
|
+
return JSGLogger._instance;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -87,7 +87,7 @@ class CACPLogger {
|
|
|
87
87
|
|
|
88
88
|
// Log initialization success
|
|
89
89
|
if (this.loggers.cacp) {
|
|
90
|
-
this.loggers.cacp.info('
|
|
90
|
+
this.loggers.cacp.info('JSG Logger initialized', {
|
|
91
91
|
environment: this.environment,
|
|
92
92
|
components: components.length,
|
|
93
93
|
projectName: configManager.getProjectName(),
|
|
@@ -98,7 +98,7 @@ class CACPLogger {
|
|
|
98
98
|
|
|
99
99
|
return this.getLoggerExports();
|
|
100
100
|
} catch (error) {
|
|
101
|
-
console.error('
|
|
101
|
+
console.error('JSG Logger initialization failed:', error);
|
|
102
102
|
// Return minimal fallback logger
|
|
103
103
|
return this.createFallbackLogger();
|
|
104
104
|
}
|
|
@@ -130,7 +130,7 @@ class CACPLogger {
|
|
|
130
130
|
|
|
131
131
|
// Log initialization success
|
|
132
132
|
if (this.loggers.cacp) {
|
|
133
|
-
this.loggers.cacp.info('
|
|
133
|
+
this.loggers.cacp.info('JSG Logger initialized (sync)', {
|
|
134
134
|
environment: this.environment,
|
|
135
135
|
components: components.length,
|
|
136
136
|
projectName: configManager.getProjectName(),
|
|
@@ -141,7 +141,7 @@ class CACPLogger {
|
|
|
141
141
|
|
|
142
142
|
return this.getLoggerExports();
|
|
143
143
|
} catch (error) {
|
|
144
|
-
console.error('
|
|
144
|
+
console.error('JSG Logger sync initialization failed:', error);
|
|
145
145
|
// Return minimal fallback logger
|
|
146
146
|
return this.createFallbackLogger();
|
|
147
147
|
}
|
|
@@ -514,7 +514,7 @@ class CACPLogger {
|
|
|
514
514
|
*/
|
|
515
515
|
static async logPerformance(operation, startTime, component = 'performance') {
|
|
516
516
|
try {
|
|
517
|
-
const instance = await
|
|
517
|
+
const instance = await JSGLogger.getInstance();
|
|
518
518
|
const logger = instance.getComponent(component);
|
|
519
519
|
const duration = performance.now() - startTime;
|
|
520
520
|
|
|
@@ -537,7 +537,7 @@ class CACPLogger {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
// Create singleton instance
|
|
540
|
-
const logger = new
|
|
540
|
+
const logger = new JSGLogger();
|
|
541
541
|
|
|
542
542
|
// Initialize synchronously with default config for immediate use
|
|
543
543
|
// (Chrome extensions and other environments that don't support top-level await)
|
|
@@ -545,15 +545,15 @@ const enhancedLoggers = logger.initSync();
|
|
|
545
545
|
|
|
546
546
|
// Make runtime controls available globally in browser for debugging
|
|
547
547
|
if (isBrowser() && typeof window !== 'undefined') {
|
|
548
|
-
window.
|
|
548
|
+
window.JSG_Logger = enhancedLoggers.controls;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
// Add static methods to the enhanced loggers for convenience
|
|
552
|
-
enhancedLoggers.getInstance =
|
|
553
|
-
enhancedLoggers.getInstanceSync =
|
|
554
|
-
enhancedLoggers.logPerformance =
|
|
555
|
-
enhancedLoggers.
|
|
552
|
+
enhancedLoggers.getInstance = JSGLogger.getInstance;
|
|
553
|
+
enhancedLoggers.getInstanceSync = JSGLogger.getInstanceSync;
|
|
554
|
+
enhancedLoggers.logPerformance = JSGLogger.logPerformance;
|
|
555
|
+
enhancedLoggers.JSGLogger = JSGLogger;
|
|
556
556
|
|
|
557
557
|
// Export both the initialized loggers and the class for advanced usage
|
|
558
558
|
export default enhancedLoggers;
|
|
559
|
-
export {logger as
|
|
559
|
+
export {logger as JSGLogger};
|
package/package.json
CHANGED