@mks2508/better-logger 0.14.0-alpha.2 → 1.0.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.
Files changed (138) hide show
  1. package/dist/chunks/{Logger-Crw1woqR.js → Logger-CTAaDeZi.js} +49 -16
  2. package/dist/chunks/{Logger-Crw1woqR.js.map → Logger-CTAaDeZi.js.map} +1 -1
  3. package/dist/chunks/{Logger-D_p3xnbq.js → Logger-D8pK7XXt.js} +2 -2
  4. package/dist/chunks/{Logger-D_p3xnbq.js.map → Logger-D8pK7XXt.js.map} +1 -1
  5. package/dist/chunks/ScopedLogger-D-7q8uVP.js +2 -0
  6. package/dist/chunks/ScopedLogger-D-7q8uVP.js.map +1 -0
  7. package/dist/chunks/ScopedLogger-hS0qSkZD.js +361 -0
  8. package/dist/chunks/ScopedLogger-hS0qSkZD.js.map +1 -0
  9. package/dist/core.js +280 -307
  10. package/dist/exports.cjs +1 -1
  11. package/dist/exports.js +1 -1
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +226 -159
  15. package/dist/index.js.map +1 -1
  16. package/dist/styling.cjs +1 -1
  17. package/dist/styling.js +2 -2
  18. package/dist/types/Logger.d.ts +11 -7
  19. package/dist/types/Logger.d.ts.map +1 -1
  20. package/dist/types/core.d.ts +122 -216
  21. package/dist/types/core.d.ts.map +1 -1
  22. package/dist/types/index.d.ts +119 -4
  23. package/dist/types/index.d.ts.map +1 -1
  24. package/package.json +2 -1
  25. package/src/Logger.ts +99 -58
  26. package/src/index.ts +32 -25
  27. package/dist/.tsbuildinfo +0 -1
  28. package/dist/Logger.d.ts +0 -708
  29. package/dist/Logger.d.ts.map +0 -1
  30. package/dist/Logger.js +0 -1124
  31. package/dist/ScopedLogger.d.ts +0 -318
  32. package/dist/ScopedLogger.d.ts.map +0 -1
  33. package/dist/ScopedLogger.js +0 -426
  34. package/dist/cli/CommandProcessor.d.ts +0 -103
  35. package/dist/cli/CommandProcessor.d.ts.map +0 -1
  36. package/dist/cli/CommandProcessor.js +0 -184
  37. package/dist/cli/commands/ConfigCommand.d.ts +0 -17
  38. package/dist/cli/commands/ConfigCommand.d.ts.map +0 -1
  39. package/dist/cli/commands/ConfigCommand.js +0 -88
  40. package/dist/cli/commands/ExportCommand.d.ts +0 -51
  41. package/dist/cli/commands/ExportCommand.d.ts.map +0 -1
  42. package/dist/cli/commands/ExportCommand.js +0 -243
  43. package/dist/cli/commands/HistoryCommand.d.ts +0 -50
  44. package/dist/cli/commands/HistoryCommand.d.ts.map +0 -1
  45. package/dist/cli/commands/HistoryCommand.js +0 -96
  46. package/dist/cli/commands/StatusCommand.d.ts +0 -33
  47. package/dist/cli/commands/StatusCommand.d.ts.map +0 -1
  48. package/dist/cli/commands/StatusCommand.js +0 -93
  49. package/dist/cli/commands/ThemeCommand.d.ts +0 -33
  50. package/dist/cli/commands/ThemeCommand.d.ts.map +0 -1
  51. package/dist/cli/commands/ThemeCommand.js +0 -79
  52. package/dist/cli/help.d.ts +0 -15
  53. package/dist/cli/help.d.ts.map +0 -1
  54. package/dist/cli/help.js +0 -118
  55. package/dist/cli/index.d.ts +0 -15
  56. package/dist/cli/index.d.ts.map +0 -1
  57. package/dist/cli/index.js +0 -46
  58. package/dist/constants.d.ts +0 -122
  59. package/dist/constants.d.ts.map +0 -1
  60. package/dist/constants.js +0 -159
  61. package/dist/core.d.ts +0 -134
  62. package/dist/core.d.ts.map +0 -1
  63. package/dist/example.d.ts +0 -18
  64. package/dist/example.d.ts.map +0 -1
  65. package/dist/example.js +0 -154
  66. package/dist/exports-module.d.ts +0 -203
  67. package/dist/exports-module.d.ts.map +0 -1
  68. package/dist/exports-module.js +0 -260
  69. package/dist/handlers/AnalyticsLogHandler.d.ts +0 -11
  70. package/dist/handlers/AnalyticsLogHandler.d.ts.map +0 -1
  71. package/dist/handlers/AnalyticsLogHandler.js +0 -19
  72. package/dist/handlers/ExportLogHandler.d.ts +0 -103
  73. package/dist/handlers/ExportLogHandler.d.ts.map +0 -1
  74. package/dist/handlers/ExportLogHandler.js +0 -516
  75. package/dist/handlers/FileLogHandler.d.ts +0 -36
  76. package/dist/handlers/FileLogHandler.d.ts.map +0 -1
  77. package/dist/handlers/FileLogHandler.js +0 -156
  78. package/dist/handlers/RemoteLogHandler.d.ts +0 -14
  79. package/dist/handlers/RemoteLogHandler.d.ts.map +0 -1
  80. package/dist/handlers/RemoteLogHandler.js +0 -37
  81. package/dist/handlers/index.d.ts +0 -8
  82. package/dist/handlers/index.d.ts.map +0 -1
  83. package/dist/handlers/index.js +0 -7
  84. package/dist/index.d.ts +0 -157
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/main.d.ts +0 -2
  87. package/dist/main.d.ts.map +0 -1
  88. package/dist/main.js +0 -139
  89. package/dist/styling/LogStyleBuilder.d.ts +0 -149
  90. package/dist/styling/LogStyleBuilder.d.ts.map +0 -1
  91. package/dist/styling/LogStyleBuilder.js +0 -289
  92. package/dist/styling/SemanticStyles.d.ts +0 -181
  93. package/dist/styling/SemanticStyles.d.ts.map +0 -1
  94. package/dist/styling/SemanticStyles.js +0 -339
  95. package/dist/styling/SmartPresets.d.ts +0 -25
  96. package/dist/styling/SmartPresets.d.ts.map +0 -1
  97. package/dist/styling/SmartPresets.js +0 -276
  98. package/dist/styling/StyleBuilder.d.ts +0 -140
  99. package/dist/styling/StyleBuilder.d.ts.map +0 -1
  100. package/dist/styling/StyleBuilder.js +0 -280
  101. package/dist/styling/banners.d.ts +0 -45
  102. package/dist/styling/banners.d.ts.map +0 -1
  103. package/dist/styling/banners.js +0 -155
  104. package/dist/styling/index.d.ts +0 -10
  105. package/dist/styling/index.d.ts.map +0 -1
  106. package/dist/styling/index.js +0 -9
  107. package/dist/styling/themes.d.ts +0 -10
  108. package/dist/styling/themes.d.ts.map +0 -1
  109. package/dist/styling/themes.js +0 -231
  110. package/dist/styling-module.d.ts +0 -185
  111. package/dist/styling-module.d.ts.map +0 -1
  112. package/dist/styling-module.js +0 -199
  113. package/dist/types/core.js +0 -28
  114. package/dist/types/handlers.d.ts +0 -88
  115. package/dist/types/handlers.d.ts.map +0 -1
  116. package/dist/types/handlers.js +0 -4
  117. package/dist/types/index.js +0 -4
  118. package/dist/utils/environment.d.ts +0 -47
  119. package/dist/utils/environment.d.ts.map +0 -1
  120. package/dist/utils/environment.js +0 -85
  121. package/dist/utils/formatting.d.ts +0 -40
  122. package/dist/utils/formatting.d.ts.map +0 -1
  123. package/dist/utils/formatting.js +0 -117
  124. package/dist/utils/index.d.ts +0 -7
  125. package/dist/utils/index.d.ts.map +0 -1
  126. package/dist/utils/index.js +0 -6
  127. package/dist/utils/opentui-detection.d.ts +0 -34
  128. package/dist/utils/opentui-detection.d.ts.map +0 -1
  129. package/dist/utils/opentui-detection.js +0 -116
  130. package/dist/utils/output.d.ts +0 -44
  131. package/dist/utils/output.d.ts.map +0 -1
  132. package/dist/utils/output.js +0 -150
  133. package/dist/utils/stackTrace.d.ts +0 -9
  134. package/dist/utils/stackTrace.d.ts.map +0 -1
  135. package/dist/utils/stackTrace.js +0 -81
  136. package/dist/utils/timestamps.d.ts +0 -20
  137. package/dist/utils/timestamps.d.ts.map +0 -1
  138. package/dist/utils/timestamps.js +0 -71
@@ -1,88 +0,0 @@
1
- /**
2
- * @fileoverview Handler and metadata type definitions for Advanced Logger
3
- */
4
- import type { LogLevel, StackInfo } from './core.js';
5
- /**
6
- * Metadata associated with each log entry
7
- */
8
- export interface LogMetadata {
9
- timestamp: string;
10
- level: LogLevel;
11
- prefix?: string;
12
- stackInfo?: StackInfo;
13
- group?: string;
14
- }
15
- /**
16
- * Interface for custom log handlers (extensibility)
17
- */
18
- export interface ILogHandler {
19
- handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void;
20
- }
21
- /**
22
- * Stored log entry for export functionality
23
- */
24
- export interface LogEntry {
25
- id: string;
26
- timestamp: string;
27
- level: LogLevel;
28
- prefix?: string;
29
- message: string;
30
- args: any[];
31
- location?: StackInfo;
32
- groupInfo?: {
33
- depth: number;
34
- groupName?: string;
35
- };
36
- }
37
- /**
38
- * Export filter options
39
- */
40
- export interface ExportFilters {
41
- levels?: LogLevel[];
42
- since?: Date | string | number;
43
- until?: Date | string | number;
44
- prefixes?: string[];
45
- excludePrefixes?: string[];
46
- withStackTrace?: boolean;
47
- errorsOnly?: boolean;
48
- last?: number;
49
- first?: number;
50
- search?: string;
51
- groupBy?: 'level' | 'prefix' | 'hour' | 'date';
52
- }
53
- /**
54
- * Export options for different formats
55
- */
56
- export interface ExportOptions {
57
- minimal?: boolean;
58
- compact?: boolean;
59
- styled?: boolean;
60
- includeMetadata?: boolean;
61
- groupBy?: ExportFilters['groupBy'];
62
- }
63
- /**
64
- * Export result with metadata
65
- */
66
- export interface ExportResult {
67
- format: string;
68
- data: string;
69
- metadata: {
70
- totalLogs: number;
71
- filteredLogs: number;
72
- exportedAt: string;
73
- filters?: ExportFilters;
74
- options?: ExportOptions;
75
- };
76
- }
77
- /**
78
- * Buffer statistics for log management
79
- */
80
- export interface BufferStats {
81
- size: number;
82
- maxSize: number;
83
- usage: number;
84
- oldestLog?: Date;
85
- newestLog?: Date;
86
- levelCounts: Record<LogLevel, number>;
87
- }
88
- //# sourceMappingURL=handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/types/handlers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,MAAM,CAAC,KAAK,EAAE,Q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aAAa,CAAC,SAAS,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,OAAO,CAAC,EAAE,aAAa,CAAC;KAC3B,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CACzC"}
@@ -1,4 +0,0 @@
1
- /**
2
- * @fileoverview Handler and metadata type definitions for Advanced Logger
3
- */
4
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * @fileoverview Type definitions exports for Advanced Logger
3
- */
4
- export { LOG_LEVELS } from './core.js';
@@ -1,47 +0,0 @@
1
- /**
2
- * @fileoverview Environment detection utilities for Universal Logger
3
- */
4
- /**
5
- * Checks if running in Node.js environment
6
- */
7
- export declare const isNode: string | false;
8
- /**
9
- * Checks if running in browser environment
10
- */
11
- export declare const isBrowser: boolean;
12
- /**
13
- * Checks if running in web worker environment
14
- */
15
- export declare const isWebWorker: boolean;
16
- /**
17
- * Checks if running in Deno environment
18
- */
19
- export declare const isDeno: boolean;
20
- /**
21
- * Gets the current runtime environment
22
- */
23
- export declare function getRuntimeEnvironment(): 'node' | 'browser' | 'webworker' | 'deno' | 'unknown';
24
- /**
25
- * Checks if colors/styling should be supported in current environment
26
- */
27
- export declare function supportsColors(): boolean;
28
- /**
29
- * Checks if CSS styling is supported (browser-only feature)
30
- */
31
- export declare function supportsCSSColors(): boolean;
32
- /**
33
- * Checks if ANSI colors are supported (terminal environments)
34
- */
35
- export declare function supportsANSIColors(): boolean;
36
- /**
37
- * Gets environment-specific information
38
- */
39
- export declare function getEnvironmentInfo(): {
40
- runtime: "unknown" | "node" | "browser" | "webworker" | "deno";
41
- supportsColors: boolean;
42
- supportsCSSColors: boolean;
43
- supportsANSIColors: boolean;
44
- isProduction: boolean;
45
- version: string;
46
- };
47
- //# sourceMappingURL=environment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,gBAEwB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,SAAS,SACmC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,WAAW,SACqD,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,MAAM,SACuB,CAAC;AAE3C;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAM7F;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAcxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAQ5C;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;;;;EAWjC"}
@@ -1,85 +0,0 @@
1
- /**
2
- * @fileoverview Environment detection utilities for Universal Logger
3
- */
4
- /**
5
- * Checks if running in Node.js environment
6
- */
7
- export const isNode = typeof process !== 'undefined' &&
8
- process.versions &&
9
- process.versions.node;
10
- /**
11
- * Checks if running in browser environment
12
- */
13
- export const isBrowser = typeof window !== 'undefined' &&
14
- typeof document !== 'undefined';
15
- /**
16
- * Checks if running in web worker environment
17
- */
18
- export const isWebWorker = typeof self !== 'undefined' &&
19
- typeof self.importScripts === 'function';
20
- /**
21
- * Checks if running in Deno environment
22
- */
23
- export const isDeno = typeof globalThis !== 'undefined' &&
24
- 'Deno' in globalThis;
25
- /**
26
- * Gets the current runtime environment
27
- */
28
- export function getRuntimeEnvironment() {
29
- if (isNode)
30
- return 'node';
31
- if (isBrowser)
32
- return 'browser';
33
- if (isWebWorker)
34
- return 'webworker';
35
- if (isDeno)
36
- return 'deno';
37
- return 'unknown';
38
- }
39
- /**
40
- * Checks if colors/styling should be supported in current environment
41
- */
42
- export function supportsColors() {
43
- if (isBrowser) {
44
- // Browser always supports CSS colors
45
- return true;
46
- }
47
- if (isNode) {
48
- // Check if Node.js supports colors
49
- return process.stdout?.isTTY === true ||
50
- process.env.FORCE_COLOR === '1' ||
51
- process.env.FORCE_COLOR === 'true';
52
- }
53
- return false;
54
- }
55
- /**
56
- * Checks if CSS styling is supported (browser-only feature)
57
- */
58
- export function supportsCSSColors() {
59
- return isBrowser;
60
- }
61
- /**
62
- * Checks if ANSI colors are supported (terminal environments)
63
- */
64
- export function supportsANSIColors() {
65
- if (isNode) {
66
- return process.stdout?.isTTY === true ||
67
- process.env.FORCE_COLOR === '1' ||
68
- process.env.FORCE_COLOR === 'true';
69
- }
70
- return false;
71
- }
72
- /**
73
- * Gets environment-specific information
74
- */
75
- export function getEnvironmentInfo() {
76
- const env = getRuntimeEnvironment();
77
- return {
78
- runtime: env,
79
- supportsColors: supportsColors(),
80
- supportsCSSColors: supportsCSSColors(),
81
- supportsANSIColors: supportsANSIColors(),
82
- isProduction: isNode ? process.env.NODE_ENV === 'production' : false,
83
- version: isNode ? process.versions.node : (isBrowser ? navigator.userAgent : 'unknown')
84
- };
85
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * @fileoverview Formatting utilities for Universal Logger
3
- */
4
- import type { LogLevel, StackInfo } from '../types/index.js';
5
- /**
6
- * Creates plain text output for any environment
7
- * No colors, no styling - maximum compatibility
8
- */
9
- export declare function createPlainOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
10
- /**
11
- * Gets the appropriate log method for the level
12
- * Uses different console methods for better semantics
13
- */
14
- export declare function getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error';
15
- /**
16
- * Create a simple log entry object for handlers
17
- */
18
- export declare function createLogEntry(level: LogLevel, message: string, args: any[], prefix?: string, stackInfo?: StackInfo | null): {
19
- timestamp: string;
20
- level: string;
21
- prefix: string | undefined;
22
- message: string;
23
- args: any[];
24
- location: {
25
- file: string;
26
- line: number;
27
- column: number;
28
- function: string | undefined;
29
- } | undefined;
30
- raw: any[];
31
- };
32
- /**
33
- * Format data for table display in plain text
34
- */
35
- export declare function formatTablePlain(data: any, columns?: string[]): string;
36
- /**
37
- * Safe object serialization for logging
38
- */
39
- export declare function safeSerialize(obj: any, maxDepth?: number, currentDepth?: number): any;
40
- //# sourceMappingURL=formatting.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CAiBR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAcnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;;;;;;;;;;;;;EAgB/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CA+BtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAU,EAAE,YAAY,GAAE,MAAU,GAAG,GAAG,CAqB3F"}
@@ -1,117 +0,0 @@
1
- /**
2
- * @fileoverview Formatting utilities for Universal Logger
3
- */
4
- import { formatTimestamp } from './timestamps.js';
5
- /**
6
- * Creates plain text output for any environment
7
- * No colors, no styling - maximum compatibility
8
- */
9
- export function createPlainOutput(level, message, prefix, stackInfo) {
10
- const timestamp = formatTimestamp();
11
- const timeStr = timestamp.slice(11, 23); // HH:MM:SS.mmm
12
- let output = `[${timeStr}] [${level.toUpperCase()}]`;
13
- if (prefix) {
14
- output += ` [${prefix}]`;
15
- }
16
- output += ` ${message}`;
17
- if (stackInfo) {
18
- output += ` (${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
19
- }
20
- return output;
21
- }
22
- /**
23
- * Gets the appropriate log method for the level
24
- * Uses different console methods for better semantics
25
- */
26
- export function getConsoleMethod(level) {
27
- switch (level) {
28
- case 'debug':
29
- return 'log';
30
- case 'info':
31
- return 'info';
32
- case 'warn':
33
- return 'warn';
34
- case 'error':
35
- case 'critical':
36
- return 'error';
37
- default:
38
- return 'log';
39
- }
40
- }
41
- /**
42
- * Create a simple log entry object for handlers
43
- */
44
- export function createLogEntry(level, message, args, prefix, stackInfo) {
45
- return {
46
- timestamp: formatTimestamp(),
47
- level: level.toUpperCase(),
48
- prefix,
49
- message,
50
- args: args.slice(1), // Exclude the first message argument
51
- location: stackInfo ? {
52
- file: stackInfo.file,
53
- line: stackInfo.line,
54
- column: stackInfo.column,
55
- function: stackInfo.function
56
- } : undefined,
57
- raw: args
58
- };
59
- }
60
- /**
61
- * Format data for table display in plain text
62
- */
63
- export function formatTablePlain(data, columns) {
64
- try {
65
- if (Array.isArray(data)) {
66
- if (data.length === 0)
67
- return '[Empty Array]';
68
- // Simple array formatting
69
- if (typeof data[0] !== 'object') {
70
- return data.map((item, i) => `${i}: ${item}`).join('\n');
71
- }
72
- // Object array formatting
73
- const keys = columns || Object.keys(data[0] || {});
74
- const header = keys.join('\t');
75
- const rows = data.map(item => keys.map(key => String(item[key] || '')).join('\t'));
76
- return [header, ...rows].join('\n');
77
- }
78
- if (typeof data === 'object' && data !== null) {
79
- // Simple object formatting
80
- return Object.entries(data)
81
- .map(([key, value]) => `${key}: ${value}`)
82
- .join('\n');
83
- }
84
- return String(data);
85
- }
86
- catch (error) {
87
- return `[Error formatting table: ${error}]`;
88
- }
89
- }
90
- /**
91
- * Safe object serialization for logging
92
- */
93
- export function safeSerialize(obj, maxDepth = 3, currentDepth = 0) {
94
- if (currentDepth >= maxDepth) {
95
- return '[Max Depth Reached]';
96
- }
97
- if (obj === null)
98
- return null;
99
- if (obj === undefined)
100
- return '[undefined]';
101
- if (typeof obj === 'function')
102
- return '[Function]';
103
- if (obj instanceof Error)
104
- return `[Error: ${obj.message}]`;
105
- if (obj instanceof Date)
106
- return obj.toISOString();
107
- if (typeof obj !== 'object')
108
- return obj;
109
- if (Array.isArray(obj)) {
110
- return obj.map(item => safeSerialize(item, maxDepth, currentDepth + 1));
111
- }
112
- const result = {};
113
- for (const [key, value] of Object.entries(obj)) {
114
- result[key] = safeSerialize(value, maxDepth, currentDepth + 1);
115
- }
116
- return result;
117
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @fileoverview Utility functions exports for Advanced Logger
3
- */
4
- export { parseStackTrace } from './stackTrace.js';
5
- export { formatTimestamp, parseRelativeTime, parseTimeInput, formatDisplayTime } from './timestamps.js';
6
- export { createStyledOutput, generateLogId, escapeHtml, safeStringify, detectDevToolsTheme, getAdaptiveColor, setupThemeChangeListener, type LevelStyleConfig } from './output.js';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,gBAAgB,EACxB,MAAM,aAAa,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * @fileoverview Utility functions exports for Advanced Logger
3
- */
4
- export { parseStackTrace } from './stackTrace.js';
5
- export { formatTimestamp, parseRelativeTime, parseTimeInput, formatDisplayTime } from './timestamps.js';
6
- export { createStyledOutput, generateLogId, escapeHtml, safeStringify, detectDevToolsTheme, getAdaptiveColor, setupThemeChangeListener } from './output.js';
@@ -1,34 +0,0 @@
1
- /**
2
- * @fileoverview OpenTUI detection and enhancement utilities for core logger
3
- */
4
- /**
5
- * Check if OpenTUI packages are available
6
- */
7
- export declare function hasOpenTUI(): Promise<boolean>;
8
- /**
9
- * Check if OpenTUI enhancement package is available
10
- */
11
- export declare function hasOpenTUILogHandler(): Promise<boolean>;
12
- /**
13
- * Dynamically enhance logger with OpenTUI if available
14
- */
15
- export declare function tryEnhanceWithOpenTUI(logger: any): Promise<boolean>;
16
- /**
17
- * Get OpenTUI environment information
18
- */
19
- export declare function getOpenTUIInfo(): Promise<{
20
- available: boolean;
21
- coreAvailable: boolean;
22
- handlerAvailable: boolean;
23
- nodeVersion: string | null;
24
- terminalSupport: boolean;
25
- }>;
26
- /**
27
- * Auto-enhance logger with best available rendering
28
- */
29
- export declare function autoEnhanceLogger(logger: any): Promise<{
30
- enhanced: boolean;
31
- method: 'opentui' | 'ansi' | 'plain';
32
- info?: any;
33
- }>;
34
- //# sourceMappingURL=opentui-detection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opentui-detection.d.ts","sourceRoot":"","sources":["../../src/utils/opentui-detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAanD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAY7D;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAkCzE;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC5B,CAAC,CAaD;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,EAAE,GAAG,CAAC;CACd,CAAC,CA0BD"}
@@ -1,116 +0,0 @@
1
- /**
2
- * @fileoverview OpenTUI detection and enhancement utilities for core logger
3
- */
4
- import { isNode } from './environment.js';
5
- /**
6
- * Check if OpenTUI packages are available
7
- */
8
- export async function hasOpenTUI() {
9
- if (!isNode) {
10
- return false; // OpenTUI is Node.js only
11
- }
12
- try {
13
- // Try to dynamically import OpenTUI core
14
- // @ts-expect-error - Optional dependency, may not be installed
15
- await import('@opentui/core');
16
- return true;
17
- }
18
- catch (error) {
19
- return false;
20
- }
21
- }
22
- /**
23
- * Check if OpenTUI enhancement package is available
24
- */
25
- export async function hasOpenTUILogHandler() {
26
- if (!isNode) {
27
- return false;
28
- }
29
- try {
30
- // @ts-expect-error - Optional dependency, may not be installed
31
- await import('@mks2508/better-logger-nodejs-opentui');
32
- return true;
33
- }
34
- catch (error) {
35
- return false;
36
- }
37
- }
38
- /**
39
- * Dynamically enhance logger with OpenTUI if available
40
- */
41
- export async function tryEnhanceWithOpenTUI(logger) {
42
- try {
43
- // Check if both OpenTUI and our enhancement package are available
44
- const [hasCore, hasEnhancer] = await Promise.all([
45
- hasOpenTUI(),
46
- hasOpenTUILogHandler()
47
- ]);
48
- if (!hasCore || !hasEnhancer) {
49
- return false;
50
- }
51
- // Dynamically import and apply enhancement
52
- // @ts-expect-error - Optional dependency, may not be installed
53
- const { enhanceLoggerWithOpenTUI } = await import('@mks2508/better-logger-nodejs-opentui');
54
- const enhanced = await enhanceLoggerWithOpenTUI(logger, {
55
- renderer: {
56
- animated: true,
57
- theme: 'auto',
58
- components: {
59
- badges: true,
60
- progressBars: false,
61
- tables: false,
62
- charts: false
63
- }
64
- }
65
- });
66
- return enhanced;
67
- }
68
- catch (error) {
69
- console.warn('Failed to enhance logger with OpenTUI:', error);
70
- return false;
71
- }
72
- }
73
- /**
74
- * Get OpenTUI environment information
75
- */
76
- export async function getOpenTUIInfo() {
77
- const [coreAvailable, handlerAvailable] = await Promise.all([
78
- hasOpenTUI(),
79
- hasOpenTUILogHandler()
80
- ]);
81
- return {
82
- available: coreAvailable && handlerAvailable,
83
- coreAvailable,
84
- handlerAvailable,
85
- nodeVersion: isNode ? process.version : null,
86
- terminalSupport: isNode ? process.stdout?.isTTY === true : false
87
- };
88
- }
89
- /**
90
- * Auto-enhance logger with best available rendering
91
- */
92
- export async function autoEnhanceLogger(logger) {
93
- // Try OpenTUI first
94
- const openTUIEnhanced = await tryEnhanceWithOpenTUI(logger);
95
- if (openTUIEnhanced) {
96
- return {
97
- enhanced: true,
98
- method: 'opentui',
99
- info: await getOpenTUIInfo()
100
- };
101
- }
102
- // Fallback to ANSI colors if in Node.js
103
- if (isNode && process.stdout?.isTTY) {
104
- return {
105
- enhanced: false,
106
- method: 'ansi',
107
- info: { reason: 'OpenTUI not available, using ANSI colors' }
108
- };
109
- }
110
- // Plain text fallback
111
- return {
112
- enhanced: false,
113
- method: 'plain',
114
- info: { reason: 'No enhanced rendering available' }
115
- };
116
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * @fileoverview Styled output creation utilities for Advanced Logger
3
- */
4
- import type { LogLevel, StackInfo, DevToolsTheme, AdaptiveColors } from '../types/index.js';
5
- /**
6
- * Style configuration for each log level
7
- */
8
- export interface LevelStyleConfig {
9
- emoji: string;
10
- label: string;
11
- background: string;
12
- color: string;
13
- border: string;
14
- shadow: string;
15
- }
16
- /**
17
- * Detects the current DevTools theme preference
18
- */
19
- export declare function detectDevToolsTheme(): DevToolsTheme;
20
- /**
21
- * Gets adaptive color based on current DevTools theme
22
- */
23
- export declare function getAdaptiveColor(colors: AdaptiveColors, theme?: DevToolsTheme): string;
24
- /**
25
- * Sets up theme change listener for dynamic updates
26
- */
27
- export declare function setupThemeChangeListener(callback: (theme: DevToolsTheme) => void): (() => void) | null;
28
- /**
29
- * Creates styled console output with multiple %c formatters
30
- */
31
- export declare function createStyledOutput(level: LogLevel, levelStyles: Record<LogLevel | 'success', LevelStyleConfig>, prefix: string | undefined, message: string, stackInfo: StackInfo | null, autoDetectTheme?: boolean): [string, ...string[]];
32
- /**
33
- * Create a unique ID for log entries
34
- */
35
- export declare function generateLogId(): string;
36
- /**
37
- * Escape HTML entities for safe HTML output
38
- */
39
- export declare function escapeHtml(text: string): string;
40
- /**
41
- * Convert objects to safe string representation for logging
42
- */
43
- export declare function safeStringify(obj: any, _maxDepth?: number): string;
44
- //# sourceMappingURL=output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK5F;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B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