@crimsonsunset/jsg-logger 1.1.2 → 1.1.3

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.
@@ -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' } });
@@ -5,7 +5,7 @@
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
  };
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.3",
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"