@mks2508/better-logger 1.1.0 → 1.2.1

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.
Files changed (49) hide show
  1. package/.claude/settings.local.json +3 -2
  2. package/CHANGELOG.md +82 -0
  3. package/bun.lock +10 -0
  4. package/dist/Logger.d.ts.map +1 -1
  5. package/dist/chunks/{Logger-Th9SfADL.js → Logger-B7L-ujY4.js} +12 -6
  6. package/dist/chunks/{Logger-Th9SfADL.js.map → Logger-B7L-ujY4.js.map} +1 -1
  7. package/dist/chunks/{Logger-C9zTFYBh.js → Logger-DzU_c5sX.js} +2 -2
  8. package/dist/chunks/{Logger-C9zTFYBh.js.map → Logger-DzU_c5sX.js.map} +1 -1
  9. package/dist/chunks/{ScopedLogger-HgV_J-ug.js → ScopedLogger-BY3-E8Ov.js} +2 -2
  10. package/dist/chunks/{ScopedLogger-HgV_J-ug.js.map → ScopedLogger-BY3-E8Ov.js.map} +1 -1
  11. package/dist/chunks/{ScopedLogger-uAAeJkfA.js → ScopedLogger-D-RbiFZn.js} +2 -2
  12. package/dist/chunks/{ScopedLogger-uAAeJkfA.js.map → ScopedLogger-D-RbiFZn.js.map} +1 -1
  13. package/dist/chunks/environment-Ba5kShbx.js +4 -0
  14. package/dist/chunks/environment-Ba5kShbx.js.map +1 -0
  15. package/dist/chunks/environment-TI2ByCPT.js +1209 -0
  16. package/dist/chunks/environment-TI2ByCPT.js.map +1 -0
  17. package/dist/chunks/{formatting-CiFnwe1I.js → formatting-Blwy-f0W.js} +2 -2
  18. package/dist/chunks/{formatting-CiFnwe1I.js.map → formatting-Blwy-f0W.js.map} +1 -1
  19. package/dist/chunks/{formatting-DIhpRCCk.js → formatting-CuNUqGks.js} +2 -2
  20. package/dist/chunks/{formatting-DIhpRCCk.js.map → formatting-CuNUqGks.js.map} +1 -1
  21. package/dist/core.cjs +1 -1
  22. package/dist/core.js +2 -2
  23. package/dist/exports.cjs +1 -1
  24. package/dist/exports.js +2 -2
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +6 -6
  27. package/dist/styling.cjs +1 -1
  28. package/dist/styling.js +3 -3
  29. package/dist/terminal/terminal-renderer.d.ts +63 -0
  30. package/dist/terminal/terminal-renderer.d.ts.map +1 -0
  31. package/dist/utils/adapter.d.ts +48 -0
  32. package/dist/utils/adapter.d.ts.map +1 -0
  33. package/dist/utils/environment-detector.d.ts +35 -0
  34. package/dist/utils/environment-detector.d.ts.map +1 -0
  35. package/dist/utils/environment.d.ts +1 -1
  36. package/dist/utils/output.d.ts +7 -2
  37. package/dist/utils/output.d.ts.map +1 -1
  38. package/dist/utils/stackTrace.d.ts.map +1 -1
  39. package/package.json +10 -2
  40. package/src/Logger.ts +21 -13
  41. package/src/terminal/terminal-renderer.ts +347 -0
  42. package/src/utils/adapter.ts +291 -0
  43. package/src/utils/environment-detector.ts +148 -0
  44. package/src/utils/output.ts +43 -1
  45. package/src/utils/stackTrace.ts +54 -5
  46. package/dist/chunks/environment-5I5unY89.js +0 -4
  47. package/dist/chunks/environment-5I5unY89.js.map +0 -1
  48. package/dist/chunks/environment-wXLQvk5g.js +0 -636
  49. package/dist/chunks/environment-wXLQvk5g.js.map +0 -1
@@ -1,636 +0,0 @@
1
- function parseStackTrace() {
2
- try {
3
- const stack = new Error().stack;
4
- if (!stack) {
5
- return null;
6
- }
7
- const lines = stack.split("\n").filter((line) => line.trim());
8
- for (let i = 1; i < lines.length; i++) {
9
- const line = lines[i];
10
- if (!line) {
11
- continue;
12
- }
13
- if (line.includes("parseStackTrace") || line.includes("Logger.") || line.includes(".log(") || line.includes("createStyledOutput")) {
14
- continue;
15
- }
16
- let match;
17
- const chromeMatch = line.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
18
- if (chromeMatch) {
19
- match = chromeMatch;
20
- } else {
21
- const firefoxMatch = line.match(/(.+?)@(.+?):(\d+):(\d+)$/);
22
- if (firefoxMatch) {
23
- match = firefoxMatch;
24
- } else {
25
- const safariMatch = line.match(/(\S+)?@(.+?):(\d+):(\d+)$/);
26
- if (safariMatch) {
27
- match = safariMatch;
28
- }
29
- }
30
- }
31
- if (!match) {
32
- continue;
33
- }
34
- const [, functionName, file, lineStr, columnStr] = match;
35
- if (!file) {
36
- continue;
37
- }
38
- const fileParts = file.split("/");
39
- const fileName = fileParts[fileParts.length - 1];
40
- if (!fileName) {
41
- continue;
42
- }
43
- const cleanFileName = fileName.split("?")[0];
44
- const lineNum = lineStr ? parseInt(lineStr, 10) : 0;
45
- const columnNum = columnStr ? parseInt(columnStr, 10) : 0;
46
- const cleanFunction = functionName && functionName.trim() ? functionName.trim() : void 0;
47
- return {
48
- file: cleanFileName ? cleanFileName : "unknown",
49
- line: lineNum,
50
- column: columnNum,
51
- function: cleanFunction
52
- };
53
- }
54
- return null;
55
- } catch {
56
- return null;
57
- }
58
- }
59
- const DEFAULT_CONFIG = {
60
- verbosity: "info",
61
- enableColors: true,
62
- enableTimestamps: true,
63
- enableStackTrace: true,
64
- theme: "default",
65
- bannerType: "simple",
66
- bufferSize: 1e3,
67
- autoDetectTheme: true,
68
- outputFormat: "auto"
69
- };
70
- const LEVEL_STYLES = {
71
- debug: {
72
- emoji: "🔍",
73
- label: "DEBUG",
74
- background: "linear-gradient(90deg, #6c757d, #495057)",
75
- color: "#ffffff",
76
- border: "1px solid #6c757d",
77
- shadow: "0 2px 4px rgba(108, 117, 125, 0.3)"
78
- },
79
- info: {
80
- emoji: "ℹ️",
81
- label: "INFO",
82
- background: "linear-gradient(90deg, #007bff, #0056b3)",
83
- color: "#ffffff",
84
- border: "1px solid #007bff",
85
- shadow: "0 2px 4px rgba(0, 123, 255, 0.3)"
86
- },
87
- warn: {
88
- emoji: "⚠️",
89
- label: "WARN",
90
- background: "linear-gradient(90deg, #ffc107, #e0a800)",
91
- color: "#000000",
92
- border: "1px solid #ffc107",
93
- shadow: "0 2px 4px rgba(255, 193, 7, 0.3)"
94
- },
95
- error: {
96
- emoji: "❌",
97
- label: "ERROR",
98
- background: "linear-gradient(90deg, #dc3545, #c82333)",
99
- color: "#ffffff",
100
- border: "1px solid #dc3545",
101
- shadow: "0 2px 4px rgba(220, 53, 69, 0.3)"
102
- },
103
- critical: {
104
- emoji: "🚨",
105
- label: "CRITICAL",
106
- background: "linear-gradient(90deg, #8B0000, #FF0000)",
107
- color: "#ffffff",
108
- border: "2px solid #FF0000",
109
- shadow: "0 4px 8px rgba(255, 0, 0, 0.4)"
110
- },
111
- success: {
112
- emoji: "✅",
113
- label: "SUCCESS",
114
- background: "linear-gradient(90deg, #28a745, #1e7e34)",
115
- color: "#ffffff",
116
- border: "1px solid #28a745",
117
- shadow: "0 2px 4px rgba(40, 167, 69, 0.3)"
118
- }
119
- };
120
- const BUFFER_LIMITS = {
121
- MIN_SIZE: 50,
122
- DEFAULT_SIZE: 1e3,
123
- MAX_SIZE: 1e4
124
- };
125
- const EXPORT_FORMATS = {
126
- json: { extension: ".json", mimeType: "application/json" },
127
- csv: { extension: ".csv", mimeType: "text/csv" },
128
- markdown: { extension: ".md", mimeType: "text/markdown" },
129
- plain: { extension: ".txt", mimeType: "text/plain" },
130
- html: { extension: ".html", mimeType: "text/html" }
131
- };
132
- const TIME_UNITS = {
133
- ms: 1,
134
- s: 1e3,
135
- m: 60 * 1e3,
136
- h: 60 * 60 * 1e3,
137
- d: 24 * 60 * 60 * 1e3
138
- };
139
- const ADAPTIVE_COLORS = {
140
- timestamp: {
141
- light: "#666666",
142
- dark: "#a0a0a0"
143
- },
144
- messageText: {
145
- light: "#2d3748",
146
- dark: "#f7fafc"
147
- },
148
- prefix: {
149
- light: "#2d3748",
150
- dark: "#e2e8f0"
151
- },
152
- prefixBackground: {
153
- light: "#2d3748",
154
- dark: "#4a5568"
155
- },
156
- location: {
157
- light: "#718096",
158
- dark: "#a0aec0"
159
- }
160
- };
161
- const BUILD_PRESETS = {
162
- /**
163
- * Configuración optimizada para Next.js builds
164
- */
165
- nextjs: {
166
- verbosity: "info",
167
- enableColors: true,
168
- enableTimestamps: false,
169
- enableStackTrace: false,
170
- autoDetectTheme: false,
171
- outputFormat: "build"
172
- },
173
- /**
174
- * Configuración para Webpack builds
175
- */
176
- webpack: {
177
- verbosity: "info",
178
- enableColors: true,
179
- enableTimestamps: true,
180
- enableStackTrace: false,
181
- autoDetectTheme: false,
182
- outputFormat: "build"
183
- },
184
- /**
185
- * Configuración para CI/CD environments
186
- */
187
- ci: {
188
- verbosity: "info",
189
- enableColors: false,
190
- enableTimestamps: true,
191
- enableStackTrace: true,
192
- autoDetectTheme: false,
193
- outputFormat: "ci"
194
- },
195
- /**
196
- * Configuración para desarrollo terminal
197
- */
198
- terminal: {
199
- verbosity: "debug",
200
- enableColors: true,
201
- enableTimestamps: true,
202
- enableStackTrace: true,
203
- autoDetectTheme: false,
204
- outputFormat: "ansi"
205
- }
206
- };
207
- const ENVIRONMENT_DETECTION = {
208
- // Next.js detection
209
- isNextJS: typeof process !== "undefined" && (process.env.NEXT_RUNTIME || process.env.NEXT_PUBLIC_VERCEL_ENV || process.argv && process.argv.some((arg) => arg.includes("next"))),
210
- // Webpack detection
211
- isWebpack: typeof process !== "undefined" && (process.env.WEBPACK_ENV || process.env.WEBPACK_BUILD || process.argv && process.argv.some((arg) => arg.includes("webpack"))),
212
- // CI/CD detection
213
- isCI: typeof process !== "undefined" && (process.env.CI || process.env.GITHUB_ACTIONS || process.env.JENKINS_URL || process.env.GITLAB_CI || process.env.TRAVIS || process.env.CIRCLECI),
214
- // Build detection
215
- isBuild: typeof process !== "undefined" && true,
216
- // Terminal with ANSI support
217
- isTerminal: typeof process !== "undefined" && (process.stdout?.isTTY === true && process.env.TERM !== "dumb")
218
- };
219
- function detectEnvironmentPreset() {
220
- if (ENVIRONMENT_DETECTION.isCI) {
221
- return "ci";
222
- }
223
- if (ENVIRONMENT_DETECTION.isNextJS) {
224
- return "nextjs";
225
- }
226
- if (ENVIRONMENT_DETECTION.isWebpack) {
227
- return "webpack";
228
- }
229
- if (ENVIRONMENT_DETECTION.isTerminal) {
230
- return "terminal";
231
- }
232
- return "terminal";
233
- }
234
- function getOptimalConfig() {
235
- const preset = detectEnvironmentPreset();
236
- return {
237
- ...DEFAULT_CONFIG,
238
- ...BUILD_PRESETS[preset]
239
- };
240
- }
241
- function formatTimestamp() {
242
- try {
243
- const now = /* @__PURE__ */ new Date();
244
- return now.toISOString();
245
- } catch {
246
- return (/* @__PURE__ */ new Date()).toISOString();
247
- }
248
- }
249
- function parseRelativeTime(timeStr) {
250
- const match = timeStr.match(/^(\d+)(ms|s|m|h|d)$/);
251
- if (!match) {
252
- throw new Error(`Invalid time format: ${timeStr}. Use format like "2h", "30m", "1d"`);
253
- }
254
- const [, amount, unit] = match;
255
- const multiplier = TIME_UNITS[unit];
256
- return parseInt(amount || "0", 10) * multiplier;
257
- }
258
- function parseTimeInput(input) {
259
- if (input instanceof Date) {
260
- return input;
261
- }
262
- if (typeof input === "number") {
263
- return new Date(Date.now() - input * TIME_UNITS.h);
264
- }
265
- if (typeof input === "string") {
266
- const isoDate = new Date(input);
267
- if (!isNaN(isoDate.getTime())) {
268
- return isoDate;
269
- }
270
- try {
271
- const ms = parseRelativeTime(input);
272
- return new Date(Date.now() - ms);
273
- } catch {
274
- throw new Error(`Invalid time format: ${input}`);
275
- }
276
- }
277
- throw new Error(`Unsupported time input type: ${typeof input}`);
278
- }
279
- function formatDisplayTime(date, format = "short") {
280
- switch (format) {
281
- case "time-only":
282
- return date.toTimeString().slice(0, 8);
283
- // HH:MM:SS
284
- case "full":
285
- return date.toISOString();
286
- case "short":
287
- default:
288
- return date.toISOString().slice(11, 23);
289
- }
290
- }
291
- class StyleBuilder {
292
- styles = [];
293
- constructor(baseStyle = "") {
294
- if (baseStyle) this.styles.push(baseStyle);
295
- }
296
- /**
297
- * Add background color or gradient
298
- */
299
- bg(background) {
300
- this.styles.push(`background: ${background}`);
301
- return this;
302
- }
303
- /**
304
- * Add text color
305
- */
306
- color(color) {
307
- this.styles.push(`color: ${color}`);
308
- return this;
309
- }
310
- /**
311
- * Add border styling
312
- */
313
- border(border) {
314
- this.styles.push(`border: ${border}`);
315
- return this;
316
- }
317
- /**
318
- * Add box shadow
319
- */
320
- shadow(shadow) {
321
- this.styles.push(`box-shadow: ${shadow}`);
322
- return this;
323
- }
324
- /**
325
- * Add padding
326
- */
327
- padding(padding) {
328
- this.styles.push(`padding: ${padding}`);
329
- return this;
330
- }
331
- /**
332
- * Add margin
333
- */
334
- margin(margin) {
335
- this.styles.push(`margin: ${margin}`);
336
- return this;
337
- }
338
- /**
339
- * Add border radius
340
- */
341
- rounded(radius = "4px") {
342
- this.styles.push(`border-radius: ${radius}`);
343
- return this;
344
- }
345
- /**
346
- * Add font weight
347
- */
348
- bold() {
349
- this.styles.push("font-weight: bold");
350
- return this;
351
- }
352
- /**
353
- * Add font styling
354
- */
355
- font(font) {
356
- this.styles.push(`font-family: ${font}`);
357
- return this;
358
- }
359
- /**
360
- * Set monospace font family (alias for common monospace fonts)
361
- */
362
- mono() {
363
- return this.font('Monaco, Consolas, "Courier New", monospace');
364
- }
365
- /**
366
- * Set system font family (alias for system fonts)
367
- */
368
- system() {
369
- return this.font('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif');
370
- }
371
- /**
372
- * Add font size
373
- */
374
- size(size) {
375
- this.styles.push(`font-size: ${size}`);
376
- return this;
377
- }
378
- /**
379
- * Add line height
380
- */
381
- lineHeight(height) {
382
- this.styles.push(`line-height: ${height}`);
383
- return this;
384
- }
385
- /**
386
- * Add text decoration
387
- */
388
- underline() {
389
- this.styles.push("text-decoration: underline");
390
- return this;
391
- }
392
- /**
393
- * Add text transform
394
- */
395
- uppercase() {
396
- this.styles.push("text-transform: uppercase");
397
- return this;
398
- }
399
- /**
400
- * Add opacity
401
- */
402
- opacity(value) {
403
- this.styles.push(`opacity: ${value}`);
404
- return this;
405
- }
406
- /**
407
- * Add display property
408
- */
409
- display(value) {
410
- this.styles.push(`display: ${value}`);
411
- return this;
412
- }
413
- /**
414
- * Add position property
415
- */
416
- position(value) {
417
- this.styles.push(`position: ${value}`);
418
- return this;
419
- }
420
- /**
421
- * Add transform property
422
- */
423
- transform(value) {
424
- this.styles.push(`transform: ${value}`);
425
- return this;
426
- }
427
- /**
428
- * Add animation property
429
- */
430
- animation(value) {
431
- this.styles.push(`animation: ${value}`);
432
- return this;
433
- }
434
- /**
435
- * Add transition property
436
- */
437
- transition(value) {
438
- this.styles.push(`transition: ${value}`);
439
- return this;
440
- }
441
- /**
442
- * Add cursor property
443
- */
444
- cursor(value) {
445
- this.styles.push(`cursor: ${value}`);
446
- return this;
447
- }
448
- /**
449
- * Add any custom CSS property
450
- */
451
- custom(property, value) {
452
- this.styles.push(`${property}: ${value}`);
453
- return this;
454
- }
455
- /**
456
- * Add any CSS property (alias for custom)
457
- */
458
- css(property, value) {
459
- return this.custom(property, value);
460
- }
461
- /**
462
- * Build the final CSS string
463
- */
464
- build() {
465
- return this.styles.join("; ");
466
- }
467
- /**
468
- * Clear all styles and start fresh
469
- */
470
- clear() {
471
- this.styles = [];
472
- return this;
473
- }
474
- /**
475
- * Clone this StyleBuilder with the same styles
476
- */
477
- clone() {
478
- const cloned = new StyleBuilder();
479
- cloned.styles = [...this.styles];
480
- return cloned;
481
- }
482
- /**
483
- * Merge another StyleBuilder's styles into this one
484
- */
485
- merge(other) {
486
- this.styles.push(...other.styles);
487
- return this;
488
- }
489
- }
490
- function createStyler() {
491
- const builder = new StyleBuilder();
492
- return new Proxy(builder, {
493
- get(target, prop) {
494
- if (prop in target) {
495
- const method = target[prop];
496
- if (typeof method === "function") {
497
- return method.bind(target);
498
- }
499
- return method;
500
- }
501
- return void 0;
502
- }
503
- });
504
- }
505
- createStyler();
506
- const StylePresets = {
507
- success: () => new StyleBuilder().bg("linear-gradient(135deg, #00b894 0%, #00a085 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
508
- error: () => new StyleBuilder().bg("linear-gradient(135deg, #e84393 0%, #d63031 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
509
- warning: () => new StyleBuilder().bg("linear-gradient(135deg, #fdcb6e 0%, #e17055 100%)").color("#2d3436").padding("4px 8px").rounded("4px").bold(),
510
- info: () => new StyleBuilder().bg("linear-gradient(135deg, #74b9ff 0%, #0984e3 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
511
- debug: () => new StyleBuilder().bg("linear-gradient(135deg, #667eea 0%, #764ba2 100%)").color("#ffffff").padding("4px 8px").rounded("4px").bold(),
512
- muted: () => new StyleBuilder().color("#6c757d").font("Monaco, Consolas, monospace").size("12px"),
513
- accent: () => new StyleBuilder().bg("#f8f9fa").color("#495057").padding("2px 6px").rounded("3px").border("1px solid #dee2e6"),
514
- neon: () => new StyleBuilder().bg("linear-gradient(135deg, #0f3460 0%, #e94560 100%)").color("#00ffff").padding("4px 8px").rounded("4px").bold().shadow("0 0 10px rgba(0, 255, 255, 0.5)")
515
- };
516
- function detectDevToolsTheme() {
517
- try {
518
- if (typeof window === "undefined" || !window.matchMedia) {
519
- return "light";
520
- }
521
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
522
- return mediaQuery.matches ? "dark" : "light";
523
- } catch (error) {
524
- console.warn("Failed to detect DevTools theme:", error);
525
- return "light";
526
- }
527
- }
528
- function getAdaptiveColor(colors, theme) {
529
- const currentTheme = theme ?? detectDevToolsTheme();
530
- return colors[currentTheme];
531
- }
532
- function setupThemeChangeListener(callback) {
533
- try {
534
- if (typeof window === "undefined" || !window.matchMedia) {
535
- return null;
536
- }
537
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
538
- const handler = (e) => {
539
- callback(e.matches ? "dark" : "light");
540
- };
541
- if (mediaQuery.addEventListener) {
542
- mediaQuery.addEventListener("change", handler);
543
- return () => mediaQuery.removeEventListener("change", handler);
544
- } else if (mediaQuery.addListener) {
545
- mediaQuery.addListener(handler);
546
- return () => mediaQuery.removeListener?.(handler);
547
- }
548
- return null;
549
- } catch (error) {
550
- console.warn("Failed to set up theme change listener:", error);
551
- return null;
552
- }
553
- }
554
- function createStyledOutput(level, levelStyles, prefix, message, stackInfo, autoDetectTheme = true) {
555
- const levelConfig = levelStyles[level];
556
- const timestamp = formatTimestamp();
557
- const currentTheme = autoDetectTheme ? detectDevToolsTheme() : "light";
558
- const timestampStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.timestamp, currentTheme)).size("11px").font("Monaco, Consolas, monospace").build();
559
- const levelStyle = new StyleBuilder().bg(levelConfig.background).color(levelConfig.color).border(levelConfig.border).shadow(levelConfig.shadow).padding("2px 8px").rounded("4px").bold().font("Monaco, Consolas, monospace").size("12px").build();
560
- const prefixStyle = new StyleBuilder().bg(getAdaptiveColor(ADAPTIVE_COLORS.prefixBackground, currentTheme)).color(getAdaptiveColor(ADAPTIVE_COLORS.prefix, currentTheme)).padding("2px 6px").rounded("3px").bold().font("Monaco, Consolas, monospace").size("11px").build();
561
- const messageStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.messageText, currentTheme)).font("system-ui, -apple-system, sans-serif").size("14px").build();
562
- const locationStyle = new StyleBuilder().color(getAdaptiveColor(ADAPTIVE_COLORS.location, currentTheme)).size("11px").font("Monaco, Consolas, monospace").build();
563
- let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
564
- const styles = [timestampStyle, levelStyle];
565
- if (prefix) {
566
- format += ` %c${prefix}`;
567
- styles.push(prefixStyle);
568
- }
569
- format += ` %c${message}`;
570
- styles.push(messageStyle);
571
- if (stackInfo) {
572
- format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
573
- styles.push(locationStyle);
574
- }
575
- return [format, ...styles];
576
- }
577
- function generateLogId() {
578
- return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
579
- }
580
- function escapeHtml(text) {
581
- const div = document.createElement("div");
582
- div.textContent = text;
583
- return div.innerHTML;
584
- }
585
- function safeStringify(obj, _maxDepth = 3) {
586
- try {
587
- return JSON.stringify(obj, (_key, value) => {
588
- if (typeof value === "function") return "[Function]";
589
- if (value instanceof Error) return `[Error: ${value.message}]`;
590
- if (value instanceof Date) return value.toISOString();
591
- if (typeof value === "undefined") return "[undefined]";
592
- return value;
593
- }, 2);
594
- } catch (error) {
595
- return String(obj);
596
- }
597
- }
598
- const isNode = typeof process !== "undefined" && process.versions && process.versions.node;
599
- const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
600
- function supportsCSSColors() {
601
- return isBrowser;
602
- }
603
- function supportsANSIColors() {
604
- if (isNode) {
605
- return process.stdout?.isTTY === true || process.env.FORCE_COLOR === "1" || process.env.FORCE_COLOR === "true";
606
- }
607
- return false;
608
- }
609
- export {
610
- ADAPTIVE_COLORS as A,
611
- BUILD_PRESETS as B,
612
- DEFAULT_CONFIG as D,
613
- ENVIRONMENT_DETECTION as E,
614
- LEVEL_STYLES as L,
615
- StylePresets as S,
616
- isBrowser as a,
617
- StyleBuilder as b,
618
- createStyledOutput as c,
619
- detectEnvironmentPreset as d,
620
- supportsANSIColors as e,
621
- formatTimestamp as f,
622
- getOptimalConfig as g,
623
- getAdaptiveColor as h,
624
- isNode as i,
625
- BUFFER_LIMITS as j,
626
- generateLogId as k,
627
- parseTimeInput as l,
628
- formatDisplayTime as m,
629
- safeStringify as n,
630
- escapeHtml as o,
631
- parseStackTrace as p,
632
- EXPORT_FORMATS as q,
633
- setupThemeChangeListener as r,
634
- supportsCSSColors as s
635
- };
636
- //# sourceMappingURL=environment-wXLQvk5g.js.map