@crimsonsunset/jsg-logger 1.1.2 → 1.1.4

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 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.CACP_Logger
446
- CACP_Logger.enableDebugMode();
447
- CACP_Logger.setDisplayOption('level', true);
448
- CACP_Logger.addFileOverride('src/popup.js', { level: 'trace' });
449
- CACP_Logger.getStats();
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,5 +1,5 @@
1
1
  /**
2
- * Component and Level Schemes for CACP Logger
2
+ * Component and Level Schemes for JSG Logger
3
3
  * Defines visual styling and organization for all logger components
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Configuration Manager for CACP Logger
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
  */
@@ -126,6 +126,11 @@ export class ConfigManager {
126
126
  * @private
127
127
  */
128
128
  async _loadConfigNode(path) {
129
+ // Only use Node.js APIs when actually in Node.js environment
130
+ if (typeof process === 'undefined' || !process.versions || !process.versions.node) {
131
+ return null;
132
+ }
133
+
129
134
  try {
130
135
  // Try dynamic import first (works with ES modules)
131
136
  const module = await import(path, { assert: { type: 'json' } });
@@ -489,7 +494,7 @@ export class ConfigManager {
489
494
  * @returns {string} Project name
490
495
  */
491
496
  getProjectName() {
492
- return this.config.projectName || 'CACP Logger';
497
+ return this.config.projectName || 'JSG Logger';
493
498
  }
494
499
 
495
500
  /**
@@ -1,5 +1,5 @@
1
1
  {
2
- "projectName": "CACP Logger",
2
+ "projectName": "JSG Logger",
3
3
  "globalLevel": "info",
4
4
  "autoRegister": true,
5
5
  "format": {
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
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "projectName": "Advanced CACP Logger Demo",
2
+ "projectName": "Advanced JSG Logger Demo",
3
3
  "globalLevel": "info",
4
4
  "timestampMode": "absolute",
5
5
  "format": {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Browser Console Formatter for CACP Logger
2
+ * Browser Console Formatter for JSG Logger
3
3
  * Beautiful console output with emoji, colors, and context trees
4
4
  * Supports file overrides, display toggles, and smart configuration
5
5
  */
@@ -1,11 +1,11 @@
1
1
  /**
2
- * CLI/Terminal Formatter for CACP Logger
2
+ * CLI/Terminal Formatter for JSG Logger
3
3
  * Uses pino-colada for beautiful terminal output with fallbacks
4
4
  */
5
5
 
6
6
  import { COMPONENT_SCHEME, LEVEL_SCHEME } from '../config/component-schemes.js';
7
7
  import pinoColada from 'pino-colada';
8
- import pinoPretty from 'pino-pretty';
8
+ // Note: pino-pretty imported conditionally to avoid browser bundle issues
9
9
 
10
10
  /**
11
11
  * Create CLI formatter using pino-colada or pino-pretty
@@ -18,28 +18,39 @@ export const createCLIFormatter = () => {
18
18
  colada.pipe(process.stdout);
19
19
  return colada;
20
20
  } catch (error) {
21
- // Fallback to pino-pretty if pino-colada not available
22
- try {
23
- return pinoPretty({
24
- colorize: true,
25
- translateTime: 'HH:MM:ss.l',
26
- messageFormat: (log, messageKey, levelLabel) => {
21
+ // Ultimate fallback - basic formatted output (works in all environments)
22
+ return {
23
+ write: (chunk) => {
24
+ try {
25
+ const log = JSON.parse(chunk);
26
+
27
+ // Get component info
27
28
  const component = COMPONENT_SCHEME[log.name] || COMPONENT_SCHEME['cacp'];
28
29
  const componentName = component.name.toUpperCase().replace(/([a-z])([A-Z])/g, '$1-$2');
30
+
31
+ // Get level info
29
32
  const level = LEVEL_SCHEME[log.level] || LEVEL_SCHEME[30];
30
- return `${level.emoji} [${componentName}] ${log[messageKey]}`;
31
- },
32
- customPrettifiers: {
33
- level: () => '', // Hide level since we show it in messageFormat
34
- time: (timestamp) => timestamp,
35
- name: () => '' // Hide name since we show it in messageFormat
33
+
34
+ // Format timestamp like pino-pretty
35
+ const timestamp = new Date(log.time).toLocaleTimeString('en-US', {
36
+ hour12: false,
37
+ hour: '2-digit',
38
+ minute: '2-digit',
39
+ second: '2-digit',
40
+ fractionalSecondDigits: 1
41
+ });
42
+
43
+ // Format message like pino-pretty messageFormat
44
+ const message = `${level.emoji} [${componentName}] ${log.msg || ''}`;
45
+
46
+ // Output with timestamp prefix
47
+ console.log(`${timestamp} ${message}`);
48
+
49
+ } catch (error) {
50
+ // Raw fallback
51
+ console.log(chunk);
36
52
  }
37
- });
38
- } catch (error) {
39
- // Ultimate fallback - basic JSON
40
- return {
41
- write: (data) => console.log(data)
42
- };
43
- }
53
+ }
54
+ };
44
55
  }
45
56
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Server/Production Formatter for CACP Logger
2
+ * Server/Production Formatter for JSG Logger
3
3
  * Structured JSON output for production logging and log aggregation
4
4
  */
5
5
 
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 CACPLogger {
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<CACPLogger>} Singleton logger instance
35
+ * @returns {Promise<JSGLogger>} Singleton logger instance
36
36
  */
37
37
  static async getInstance(options = {}) {
38
- if (!CACPLogger._instance) {
39
- CACPLogger._instance = new CACPLogger();
40
- await CACPLogger._instance.init(options);
38
+ if (!JSGLogger._instance) {
39
+ JSGLogger._instance = new JSGLogger();
40
+ await JSGLogger._instance.init(options);
41
41
  }
42
- return CACPLogger._instance;
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 {CACPLogger} Singleton logger instance
48
+ * @returns {JSGLogger} Singleton logger instance
49
49
  */
50
50
  static getInstanceSync(options = {}) {
51
- if (!CACPLogger._instance) {
52
- CACPLogger._instance = new CACPLogger();
53
- CACPLogger._instance.initSync(options);
51
+ if (!JSGLogger._instance) {
52
+ JSGLogger._instance = new JSGLogger();
53
+ JSGLogger._instance.initSync(options);
54
54
  }
55
- return CACPLogger._instance;
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('CACP Logger initialized', {
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('CACP Logger initialization failed:', 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('CACP Logger initialized (sync)', {
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('CACP Logger sync initialization failed:', 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 CACPLogger.getInstance();
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 CACPLogger();
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.CACP_Logger = enhancedLoggers.controls;
548
+ window.JSG_Logger = enhancedLoggers.controls;
549
549
  }
550
550
 
551
551
  // Add static methods to the enhanced loggers for convenience
552
- enhancedLoggers.getInstance = CACPLogger.getInstance;
553
- enhancedLoggers.getInstanceSync = CACPLogger.getInstanceSync;
554
- enhancedLoggers.logPerformance = CACPLogger.logPerformance;
555
- enhancedLoggers.CACPLogger = CACPLogger;
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 CACPLogger};
559
+ export {logger as JSGLogger};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crimsonsunset/jsg-logger",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
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",
@@ -30,8 +30,7 @@
30
30
  "pino": "^9.7.0"
31
31
  },
32
32
  "devDependencies": {
33
- "pino-colada": "^2.2.2",
34
- "pino-pretty": "^13.1.1"
33
+ "pino-colada": "^2.2.2"
35
34
  },
36
35
  "peerDependencies": {
37
36
  "pino-colada": "^2.2.2"