traceperf 0.2.1 → 1.3.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.
- package/README.md +608 -253
- package/dist/__tests__/helpers/console.d.ts +9 -0
- package/dist/__tests__/helpers/console.js +25 -0
- package/dist/__tests__/helpers/console.js.map +1 -0
- package/dist/auto.d.ts +30 -0
- package/dist/auto.js +91 -0
- package/dist/auto.js.map +1 -0
- package/dist/browser.d.ts +52 -144
- package/dist/browser.js +112 -439
- package/dist/browser.js.map +1 -1
- package/dist/cli.d.ts +68 -0
- package/dist/cli.js +528 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/allocations.d.ts +38 -0
- package/dist/core/allocations.js +85 -0
- package/dist/core/allocations.js.map +1 -0
- package/dist/core/cpu-profile.d.ts +84 -0
- package/dist/core/cpu-profile.js +181 -0
- package/dist/core/cpu-profile.js.map +1 -0
- package/dist/core/env.d.ts +10 -0
- package/dist/core/env.js +40 -0
- package/dist/core/env.js.map +1 -0
- package/dist/core/event-loop.d.ts +30 -0
- package/dist/core/event-loop.js +43 -0
- package/dist/core/event-loop.js.map +1 -0
- package/dist/core/explain.d.ts +48 -0
- package/dist/core/explain.js +236 -0
- package/dist/core/explain.js.map +1 -0
- package/dist/core/exporters.d.ts +111 -0
- package/dist/core/exporters.js +236 -0
- package/dist/core/exporters.js.map +1 -0
- package/dist/core/index.d.ts +9 -3
- package/dist/core/index.js +9 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/optimized-performance-monitor.d.ts +180 -26
- package/dist/core/optimized-performance-monitor.js +687 -175
- package/dist/core/optimized-performance-monitor.js.map +1 -1
- package/dist/core/prometheus.d.ts +36 -0
- package/dist/core/prometheus.js +93 -0
- package/dist/core/prometheus.js.map +1 -0
- package/dist/core/records.d.ts +97 -0
- package/dist/core/records.js +87 -0
- package/dist/core/records.js.map +1 -0
- package/dist/core/stats.d.ts +45 -0
- package/dist/core/stats.js +136 -0
- package/dist/core/stats.js.map +1 -0
- package/dist/core/timeline.d.ts +28 -0
- package/dist/core/timeline.js +65 -0
- package/dist/core/timeline.js.map +1 -0
- package/dist/drivers.d.ts +51 -0
- package/dist/drivers.js +205 -0
- package/dist/drivers.js.map +1 -0
- package/dist/esm/auto.d.ts +30 -0
- package/dist/esm/auto.js +87 -0
- package/dist/esm/auto.js.map +1 -0
- package/dist/esm/browser.d.ts +52 -144
- package/dist/esm/browser.js +101 -445
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/cli.d.ts +68 -0
- package/dist/esm/cli.js +520 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/core/allocations.d.ts +38 -0
- package/dist/esm/core/allocations.js +82 -0
- package/dist/esm/core/allocations.js.map +1 -0
- package/dist/esm/core/cpu-profile.d.ts +84 -0
- package/dist/esm/core/cpu-profile.js +176 -0
- package/dist/esm/core/cpu-profile.js.map +1 -0
- package/dist/esm/core/env.d.ts +10 -0
- package/dist/esm/core/env.js +35 -0
- package/dist/esm/core/env.js.map +1 -0
- package/dist/esm/core/event-loop.d.ts +30 -0
- package/dist/esm/core/event-loop.js +40 -0
- package/dist/esm/core/event-loop.js.map +1 -0
- package/dist/esm/core/explain.d.ts +48 -0
- package/dist/esm/core/explain.js +232 -0
- package/dist/esm/core/explain.js.map +1 -0
- package/dist/esm/core/exporters.d.ts +111 -0
- package/dist/esm/core/exporters.js +229 -0
- package/dist/esm/core/exporters.js.map +1 -0
- package/dist/esm/core/index.d.ts +10 -4
- package/dist/esm/core/index.js +10 -4
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/optimized-performance-monitor.d.ts +180 -26
- package/dist/esm/core/optimized-performance-monitor.js +685 -173
- package/dist/esm/core/optimized-performance-monitor.js.map +1 -1
- package/dist/esm/core/prometheus.d.ts +36 -0
- package/dist/esm/core/prometheus.js +89 -0
- package/dist/esm/core/prometheus.js.map +1 -0
- package/dist/esm/core/records.d.ts +97 -0
- package/dist/esm/core/records.js +82 -0
- package/dist/esm/core/records.js.map +1 -0
- package/dist/esm/core/stats.d.ts +45 -0
- package/dist/esm/core/stats.js +131 -0
- package/dist/esm/core/stats.js.map +1 -0
- package/dist/esm/core/timeline.d.ts +28 -0
- package/dist/esm/core/timeline.js +62 -0
- package/dist/esm/core/timeline.js.map +1 -0
- package/dist/esm/drivers.d.ts +51 -0
- package/dist/esm/drivers.js +197 -0
- package/dist/esm/drivers.js.map +1 -0
- package/dist/esm/index.d.ts +13 -5
- package/dist/esm/index.js +21 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instrument.d.ts +88 -0
- package/dist/esm/instrument.js +274 -0
- package/dist/esm/instrument.js.map +1 -0
- package/dist/esm/integrations.d.ts +70 -0
- package/dist/esm/integrations.js +197 -0
- package/dist/esm/integrations.js.map +1 -0
- package/dist/esm/node-builtins.d.ts +1 -0
- package/dist/esm/node-builtins.js +32 -0
- package/dist/esm/node-builtins.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/register.d.ts +20 -0
- package/dist/esm/register.js +98 -0
- package/dist/esm/register.js.map +1 -0
- package/dist/esm/report-html.d.ts +11 -0
- package/dist/esm/report-html.js +106 -0
- package/dist/esm/report-html.js.map +1 -0
- package/dist/esm/types/index.d.ts +4 -80
- package/dist/esm/types/index.js +1 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/options.d.ts +72 -0
- package/dist/esm/types/options.js +2 -0
- package/dist/esm/types/options.js.map +1 -0
- package/dist/esm/watch.d.ts +17 -0
- package/dist/esm/watch.js +87 -0
- package/dist/esm/watch.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +26 -29
- package/dist/index.js.map +1 -1
- package/dist/instrument.d.ts +88 -0
- package/dist/instrument.js +282 -0
- package/dist/instrument.js.map +1 -0
- package/dist/integrations.d.ts +70 -0
- package/dist/integrations.js +205 -0
- package/dist/integrations.js.map +1 -0
- package/dist/node-builtins.d.ts +1 -0
- package/dist/node-builtins.js +67 -0
- package/dist/node-builtins.js.map +1 -0
- package/dist/register.d.ts +20 -0
- package/dist/register.js +103 -0
- package/dist/register.js.map +1 -0
- package/dist/report-html.d.ts +11 -0
- package/dist/report-html.js +109 -0
- package/dist/report-html.js.map +1 -0
- package/dist/traceperf.browser.js +1910 -0
- package/dist/traceperf.browser.min.js +6 -0
- package/dist/types/index.d.ts +4 -80
- package/dist/types/index.js +1 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +72 -0
- package/dist/types/{config.js → options.js} +1 -1
- package/dist/types/options.js.map +1 -0
- package/dist/watch.d.ts +17 -0
- package/dist/watch.js +90 -0
- package/dist/watch.js.map +1 -0
- package/package.json +99 -19
- package/dist/core/config.d.ts +0 -77
- package/dist/core/config.js +0 -116
- package/dist/core/config.js.map +0 -1
- package/dist/core/constants.d.ts +0 -78
- package/dist/core/constants.js +0 -109
- package/dist/core/constants.js.map +0 -1
- package/dist/core/logger.d.ts +0 -97
- package/dist/core/logger.js +0 -186
- package/dist/core/logger.js.map +0 -1
- package/dist/esm/core/config.d.ts +0 -77
- package/dist/esm/core/config.js +0 -112
- package/dist/esm/core/config.js.map +0 -1
- package/dist/esm/core/constants.d.ts +0 -78
- package/dist/esm/core/constants.js +0 -106
- package/dist/esm/core/constants.js.map +0 -1
- package/dist/esm/core/logger.d.ts +0 -97
- package/dist/esm/core/logger.js +0 -182
- package/dist/esm/core/logger.js.map +0 -1
- package/dist/esm/formatters/ascii.d.ts +0 -52
- package/dist/esm/formatters/ascii.js +0 -100
- package/dist/esm/formatters/ascii.js.map +0 -1
- package/dist/esm/formatters/cli.d.ts +0 -50
- package/dist/esm/formatters/cli.js +0 -96
- package/dist/esm/formatters/cli.js.map +0 -1
- package/dist/esm/formatters/index.d.ts +0 -3
- package/dist/esm/formatters/index.js +0 -4
- package/dist/esm/formatters/index.js.map +0 -1
- package/dist/esm/formatters/json.d.ts +0 -45
- package/dist/esm/formatters/json.js +0 -85
- package/dist/esm/formatters/json.js.map +0 -1
- package/dist/esm/trackers/execution.d.ts +0 -101
- package/dist/esm/trackers/execution.js +0 -226
- package/dist/esm/trackers/execution.js.map +0 -1
- package/dist/esm/trackers/index.d.ts +0 -2
- package/dist/esm/trackers/index.js +0 -3
- package/dist/esm/trackers/index.js.map +0 -1
- package/dist/esm/trackers/performance.d.ts +0 -68
- package/dist/esm/trackers/performance.js +0 -112
- package/dist/esm/trackers/performance.js.map +0 -1
- package/dist/esm/types/config.d.ts +0 -142
- package/dist/esm/types/config.js +0 -2
- package/dist/esm/types/config.js.map +0 -1
- package/dist/esm/types/logger.d.ts +0 -147
- package/dist/esm/types/logger.js +0 -2
- package/dist/esm/types/logger.js.map +0 -1
- package/dist/esm/utils/colors.d.ts +0 -87
- package/dist/esm/utils/colors.js +0 -146
- package/dist/esm/utils/colors.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -3
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/proxy-tracker.d.ts +0 -68
- package/dist/esm/utils/proxy-tracker.js +0 -127
- package/dist/esm/utils/proxy-tracker.js.map +0 -1
- package/dist/esm/utils/stack.d.ts +0 -63
- package/dist/esm/utils/stack.js +0 -110
- package/dist/esm/utils/stack.js.map +0 -1
- package/dist/esm/utils/string.d.ts +0 -29
- package/dist/esm/utils/string.js +0 -45
- package/dist/esm/utils/string.js.map +0 -1
- package/dist/esm/utils/timing.d.ts +0 -65
- package/dist/esm/utils/timing.js +0 -99
- package/dist/esm/utils/timing.js.map +0 -1
- package/dist/formatters/ascii.d.ts +0 -52
- package/dist/formatters/ascii.js +0 -104
- package/dist/formatters/ascii.js.map +0 -1
- package/dist/formatters/cli.d.ts +0 -50
- package/dist/formatters/cli.js +0 -100
- package/dist/formatters/cli.js.map +0 -1
- package/dist/formatters/index.d.ts +0 -3
- package/dist/formatters/index.js +0 -20
- package/dist/formatters/index.js.map +0 -1
- package/dist/formatters/json.d.ts +0 -45
- package/dist/formatters/json.js +0 -89
- package/dist/formatters/json.js.map +0 -1
- package/dist/trackers/execution.d.ts +0 -101
- package/dist/trackers/execution.js +0 -230
- package/dist/trackers/execution.js.map +0 -1
- package/dist/trackers/index.d.ts +0 -2
- package/dist/trackers/index.js +0 -19
- package/dist/trackers/index.js.map +0 -1
- package/dist/trackers/performance.d.ts +0 -68
- package/dist/trackers/performance.js +0 -116
- package/dist/trackers/performance.js.map +0 -1
- package/dist/types/config.d.ts +0 -142
- package/dist/types/config.js.map +0 -1
- package/dist/types/logger.d.ts +0 -147
- package/dist/types/logger.js +0 -3
- package/dist/types/logger.js.map +0 -1
- package/dist/types.d.ts +0 -65
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -87
- package/dist/utils/colors.js +0 -160
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -20
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/proxy-tracker.d.ts +0 -68
- package/dist/utils/proxy-tracker.js +0 -131
- package/dist/utils/proxy-tracker.js.map +0 -1
- package/dist/utils/stack.d.ts +0 -63
- package/dist/utils/stack.js +0 -116
- package/dist/utils/stack.js.map +0 -1
- package/dist/utils/string.d.ts +0 -29
- package/dist/utils/string.js +0 -50
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/timing.d.ts +0 -65
- package/dist/utils/timing.js +0 -106
- package/dist/utils/timing.js.map +0 -1
package/dist/esm/utils/stack.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for managing call stacks and function tracking
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extract the name of a function
|
|
6
|
-
*
|
|
7
|
-
* @param fn - The function to extract the name from
|
|
8
|
-
* @returns The function name or a placeholder if not available
|
|
9
|
-
*/
|
|
10
|
-
export function getFunctionName(fn) {
|
|
11
|
-
if (fn.name) {
|
|
12
|
-
return fn.name;
|
|
13
|
-
}
|
|
14
|
-
// Try to extract name from function toString()
|
|
15
|
-
const fnStr = fn.toString();
|
|
16
|
-
const nameMatch = fnStr.match(/function\s+([^(]+)/);
|
|
17
|
-
if (nameMatch) {
|
|
18
|
-
return nameMatch[1].trim();
|
|
19
|
-
}
|
|
20
|
-
// For arrow functions or anonymous functions
|
|
21
|
-
const arrowMatch = fnStr.match(/^\s*(?:async\s+)?(?:\([^)]*\)|\w+)\s*=>/);
|
|
22
|
-
if (arrowMatch) {
|
|
23
|
-
return '<arrow function>';
|
|
24
|
-
}
|
|
25
|
-
return '<anonymous>';
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the current call stack
|
|
29
|
-
*
|
|
30
|
-
* @returns An array of function names in the call stack
|
|
31
|
-
*/
|
|
32
|
-
export function getCallStack() {
|
|
33
|
-
const stack = new Error().stack;
|
|
34
|
-
if (!stack) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
// Parse the stack trace
|
|
38
|
-
return stack
|
|
39
|
-
.split('\n')
|
|
40
|
-
.slice(2) // Skip the Error and this function
|
|
41
|
-
.map(line => {
|
|
42
|
-
const match = line.match(/at\s+([^\s]+)/);
|
|
43
|
-
return match ? match[1] : line.trim();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* CallStackManager - Manages a call stack for execution tracking
|
|
48
|
-
*/
|
|
49
|
-
export class CallStackManager {
|
|
50
|
-
constructor() {
|
|
51
|
-
this._stack = [];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Push a function name onto the call stack
|
|
55
|
-
*
|
|
56
|
-
* @param name - The function name
|
|
57
|
-
* @returns The current stack depth
|
|
58
|
-
*/
|
|
59
|
-
push(name) {
|
|
60
|
-
this._stack.push(name);
|
|
61
|
-
return this._stack.length;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Pop a function name from the call stack
|
|
65
|
-
*
|
|
66
|
-
* @returns The popped function name or undefined if the stack is empty
|
|
67
|
-
*/
|
|
68
|
-
pop() {
|
|
69
|
-
return this._stack.pop();
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get the current call stack
|
|
73
|
-
*
|
|
74
|
-
* @returns A copy of the current call stack
|
|
75
|
-
*/
|
|
76
|
-
getStack() {
|
|
77
|
-
return [...this._stack];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the current stack depth
|
|
81
|
-
*
|
|
82
|
-
* @returns The current stack depth
|
|
83
|
-
*/
|
|
84
|
-
getDepth() {
|
|
85
|
-
return this._stack.length;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Clear the call stack
|
|
89
|
-
*/
|
|
90
|
-
clear() {
|
|
91
|
-
this._stack = [];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get the current function name (top of the stack)
|
|
95
|
-
*
|
|
96
|
-
* @returns The current function name or undefined if the stack is empty
|
|
97
|
-
*/
|
|
98
|
-
getCurrentFunction() {
|
|
99
|
-
return this._stack[this._stack.length - 1];
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get the parent function name
|
|
103
|
-
*
|
|
104
|
-
* @returns The parent function name or undefined if there is no parent
|
|
105
|
-
*/
|
|
106
|
-
getParentFunction() {
|
|
107
|
-
return this._stack[this._stack.length - 2];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=stack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/utils/stack.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,EAAY;IAC1C,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC,IAAI,CAAC;IACjB,CAAC;IAED,+CAA+C;IAC/C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,KAAK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C,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACI,kBAAkB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,iBAAiB;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Center a string with padding
|
|
6
|
-
*
|
|
7
|
-
* @param str - The string to center
|
|
8
|
-
* @param length - The total length of the returned string
|
|
9
|
-
* @param char - The character to use for padding (default: space)
|
|
10
|
-
* @returns The padded string
|
|
11
|
-
*/
|
|
12
|
-
export declare function padCenter(str: string, length: number, char?: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Truncate a string to a specified length and add ellipsis if needed
|
|
15
|
-
*
|
|
16
|
-
* @param str - The string to truncate
|
|
17
|
-
* @param maxLength - The maximum length allowed
|
|
18
|
-
* @returns The truncated string
|
|
19
|
-
*/
|
|
20
|
-
export declare function truncate(str: string, maxLength: number): string;
|
|
21
|
-
/**
|
|
22
|
-
* Ensure that the string is at least a certain length
|
|
23
|
-
*
|
|
24
|
-
* @param str - The string to pad
|
|
25
|
-
* @param length - The minimum length desired
|
|
26
|
-
* @param char - The character to use for padding (default: space)
|
|
27
|
-
* @returns The padded string
|
|
28
|
-
*/
|
|
29
|
-
export declare function padEnd(str: string, length: number, char?: string): string;
|
package/dist/esm/utils/string.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Center a string with padding
|
|
6
|
-
*
|
|
7
|
-
* @param str - The string to center
|
|
8
|
-
* @param length - The total length of the returned string
|
|
9
|
-
* @param char - The character to use for padding (default: space)
|
|
10
|
-
* @returns The padded string
|
|
11
|
-
*/
|
|
12
|
-
export function padCenter(str, length, char = ' ') {
|
|
13
|
-
if (str.length >= length)
|
|
14
|
-
return str;
|
|
15
|
-
const leftPadding = Math.floor((length - str.length) / 2);
|
|
16
|
-
const rightPadding = length - str.length - leftPadding;
|
|
17
|
-
return char.repeat(leftPadding) + str + char.repeat(rightPadding);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Truncate a string to a specified length and add ellipsis if needed
|
|
21
|
-
*
|
|
22
|
-
* @param str - The string to truncate
|
|
23
|
-
* @param maxLength - The maximum length allowed
|
|
24
|
-
* @returns The truncated string
|
|
25
|
-
*/
|
|
26
|
-
export function truncate(str, maxLength) {
|
|
27
|
-
if (str.length <= maxLength)
|
|
28
|
-
return str;
|
|
29
|
-
const ellipsis = '...';
|
|
30
|
-
return str.substring(0, maxLength - ellipsis.length) + ellipsis;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Ensure that the string is at least a certain length
|
|
34
|
-
*
|
|
35
|
-
* @param str - The string to pad
|
|
36
|
-
* @param length - The minimum length desired
|
|
37
|
-
* @param char - The character to use for padding (default: space)
|
|
38
|
-
* @returns The padded string
|
|
39
|
-
*/
|
|
40
|
-
export function padEnd(str, length, char = ' ') {
|
|
41
|
-
if (str.length >= length)
|
|
42
|
-
return str;
|
|
43
|
-
return str + char.repeat(length - str.length);
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=string.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAc,EAAE,OAAe,GAAG;IACvE,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IAErC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC;IAEvD,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,SAAiB;IACrD,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC;IAExC,MAAM,QAAQ,GAAG,KAAK,CAAC;IACvB,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,MAAc,EAAE,OAAe,GAAG;IACpE,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IAErC,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-resolution timing utilities for performance tracking
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Get the current high-resolution time
|
|
6
|
-
*
|
|
7
|
-
* @returns The current high-resolution time
|
|
8
|
-
*/
|
|
9
|
-
export declare function getHighResTime(): [number, number];
|
|
10
|
-
/**
|
|
11
|
-
* Calculate the duration between a start time and now
|
|
12
|
-
*
|
|
13
|
-
* @param startTime - The start time from getHighResTime()
|
|
14
|
-
* @returns The duration in milliseconds
|
|
15
|
-
*/
|
|
16
|
-
export declare function getDuration(startTime: [number, number]): number;
|
|
17
|
-
/**
|
|
18
|
-
* Format a duration in milliseconds to a human-readable string
|
|
19
|
-
*
|
|
20
|
-
* @param duration - The duration in milliseconds
|
|
21
|
-
* @returns A formatted string (e.g., "1.23ms", "1.23s")
|
|
22
|
-
*/
|
|
23
|
-
export declare function formatDuration(duration: number): string;
|
|
24
|
-
/**
|
|
25
|
-
* A simple timer class for measuring durations
|
|
26
|
-
*/
|
|
27
|
-
export declare class Timer {
|
|
28
|
-
private _startTime;
|
|
29
|
-
private _endTime;
|
|
30
|
-
private _label;
|
|
31
|
-
/**
|
|
32
|
-
* Create a new Timer instance
|
|
33
|
-
*
|
|
34
|
-
* @param label - A label for the timer
|
|
35
|
-
*/
|
|
36
|
-
constructor(label: string);
|
|
37
|
-
/**
|
|
38
|
-
* Stop the timer
|
|
39
|
-
*
|
|
40
|
-
* @returns The duration in milliseconds
|
|
41
|
-
*/
|
|
42
|
-
stop(): number;
|
|
43
|
-
/**
|
|
44
|
-
* Get the duration of the timer
|
|
45
|
-
*
|
|
46
|
-
* @returns The duration in milliseconds
|
|
47
|
-
*/
|
|
48
|
-
getDuration(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Get the label of the timer
|
|
51
|
-
*
|
|
52
|
-
* @returns The timer label
|
|
53
|
-
*/
|
|
54
|
-
getLabel(): string;
|
|
55
|
-
/**
|
|
56
|
-
* Reset the timer
|
|
57
|
-
*/
|
|
58
|
-
reset(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get a formatted string with the duration
|
|
61
|
-
*
|
|
62
|
-
* @returns A formatted string (e.g., "label: 1.23ms")
|
|
63
|
-
*/
|
|
64
|
-
toString(): string;
|
|
65
|
-
}
|
package/dist/esm/utils/timing.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-resolution timing utilities for performance tracking
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Get the current high-resolution time
|
|
6
|
-
*
|
|
7
|
-
* @returns The current high-resolution time
|
|
8
|
-
*/
|
|
9
|
-
export function getHighResTime() {
|
|
10
|
-
return process.hrtime();
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Calculate the duration between a start time and now
|
|
14
|
-
*
|
|
15
|
-
* @param startTime - The start time from getHighResTime()
|
|
16
|
-
* @returns The duration in milliseconds
|
|
17
|
-
*/
|
|
18
|
-
export function getDuration(startTime) {
|
|
19
|
-
const [seconds, nanoseconds] = process.hrtime(startTime);
|
|
20
|
-
return seconds * 1000 + nanoseconds / 1000000;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Format a duration in milliseconds to a human-readable string
|
|
24
|
-
*
|
|
25
|
-
* @param duration - The duration in milliseconds
|
|
26
|
-
* @returns A formatted string (e.g., "1.23ms", "1.23s")
|
|
27
|
-
*/
|
|
28
|
-
export function formatDuration(duration) {
|
|
29
|
-
if (duration < 1) {
|
|
30
|
-
return `${(duration * 1000).toFixed(2)}μs`;
|
|
31
|
-
}
|
|
32
|
-
else if (duration < 1000) {
|
|
33
|
-
return `${duration.toFixed(2)}ms`;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return `${(duration / 1000).toFixed(2)}s`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A simple timer class for measuring durations
|
|
41
|
-
*/
|
|
42
|
-
export class Timer {
|
|
43
|
-
/**
|
|
44
|
-
* Create a new Timer instance
|
|
45
|
-
*
|
|
46
|
-
* @param label - A label for the timer
|
|
47
|
-
*/
|
|
48
|
-
constructor(label) {
|
|
49
|
-
this._endTime = null;
|
|
50
|
-
this._startTime = getHighResTime();
|
|
51
|
-
this._label = label;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Stop the timer
|
|
55
|
-
*
|
|
56
|
-
* @returns The duration in milliseconds
|
|
57
|
-
*/
|
|
58
|
-
stop() {
|
|
59
|
-
if (this._endTime === null) {
|
|
60
|
-
this._endTime = getHighResTime();
|
|
61
|
-
}
|
|
62
|
-
return this.getDuration();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get the duration of the timer
|
|
66
|
-
*
|
|
67
|
-
* @returns The duration in milliseconds
|
|
68
|
-
*/
|
|
69
|
-
getDuration() {
|
|
70
|
-
if (this._endTime === null) {
|
|
71
|
-
return getDuration(this._startTime);
|
|
72
|
-
}
|
|
73
|
-
return getDuration(this._startTime);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the label of the timer
|
|
77
|
-
*
|
|
78
|
-
* @returns The timer label
|
|
79
|
-
*/
|
|
80
|
-
getLabel() {
|
|
81
|
-
return this._label;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Reset the timer
|
|
85
|
-
*/
|
|
86
|
-
reset() {
|
|
87
|
-
this._startTime = getHighResTime();
|
|
88
|
-
this._endTime = null;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get a formatted string with the duration
|
|
92
|
-
*
|
|
93
|
-
* @returns A formatted string (e.g., "label: 1.23ms")
|
|
94
|
-
*/
|
|
95
|
-
toString() {
|
|
96
|
-
return `${this._label}: ${formatDuration(this.getDuration())}`;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=timing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../../src/utils/timing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH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AU,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,UAAU,GAAG,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACb,OAAO,GAAG,IAAI,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execution data for a function call
|
|
3
|
-
*/
|
|
4
|
-
export interface ExecutionData {
|
|
5
|
-
name: string;
|
|
6
|
-
duration: number;
|
|
7
|
-
isSlow: boolean;
|
|
8
|
-
memoryUsage?: number;
|
|
9
|
-
level: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* ASCII art generator for execution flow charts
|
|
13
|
-
*/
|
|
14
|
-
export declare class AsciiArtGenerator {
|
|
15
|
-
private _boxWidth;
|
|
16
|
-
/**
|
|
17
|
-
* Create a new AsciiArtGenerator instance
|
|
18
|
-
*
|
|
19
|
-
* @param options - Generator options
|
|
20
|
-
*/
|
|
21
|
-
constructor(options?: {
|
|
22
|
-
boxWidth?: number;
|
|
23
|
-
});
|
|
24
|
-
/**
|
|
25
|
-
* Generate a flow chart for a sequence of function executions
|
|
26
|
-
*
|
|
27
|
-
* @param executions - Array of execution data
|
|
28
|
-
* @returns ASCII art flow chart
|
|
29
|
-
*/
|
|
30
|
-
generateFlowChart(executions: ExecutionData[]): string;
|
|
31
|
-
/**
|
|
32
|
-
* Generate a box for a function execution
|
|
33
|
-
*
|
|
34
|
-
* @param execution - The execution data
|
|
35
|
-
* @returns ASCII art box
|
|
36
|
-
*/
|
|
37
|
-
private generateFunctionBox;
|
|
38
|
-
/**
|
|
39
|
-
* Generate an arrow between function boxes
|
|
40
|
-
*
|
|
41
|
-
* @param levelDiff - Difference in nesting level
|
|
42
|
-
* @returns ASCII art arrow
|
|
43
|
-
*/
|
|
44
|
-
private generateArrow;
|
|
45
|
-
/**
|
|
46
|
-
* Format memory usage in a human-readable format
|
|
47
|
-
*
|
|
48
|
-
* @param bytes - Memory usage in bytes
|
|
49
|
-
* @returns Formatted memory usage
|
|
50
|
-
*/
|
|
51
|
-
private formatMemory;
|
|
52
|
-
}
|
package/dist/formatters/ascii.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsciiArtGenerator = void 0;
|
|
4
|
-
const constants_1 = require("../core/constants");
|
|
5
|
-
const timing_1 = require("../utils/timing");
|
|
6
|
-
/**
|
|
7
|
-
* ASCII art generator for execution flow charts
|
|
8
|
-
*/
|
|
9
|
-
class AsciiArtGenerator {
|
|
10
|
-
/**
|
|
11
|
-
* Create a new AsciiArtGenerator instance
|
|
12
|
-
*
|
|
13
|
-
* @param options - Generator options
|
|
14
|
-
*/
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
var _a;
|
|
17
|
-
this._boxWidth = (_a = options.boxWidth) !== null && _a !== void 0 ? _a : 30;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Generate a flow chart for a sequence of function executions
|
|
21
|
-
*
|
|
22
|
-
* @param executions - Array of execution data
|
|
23
|
-
* @returns ASCII art flow chart
|
|
24
|
-
*/
|
|
25
|
-
generateFlowChart(executions) {
|
|
26
|
-
let chart = '';
|
|
27
|
-
for (let i = 0; i < executions.length; i++) {
|
|
28
|
-
const execution = executions[i];
|
|
29
|
-
// Generate box for function
|
|
30
|
-
chart += this.generateFunctionBox(execution);
|
|
31
|
-
// Add arrow to next function if not the last one
|
|
32
|
-
if (i < executions.length - 1) {
|
|
33
|
-
chart += this.generateArrow(executions[i + 1].level - execution.level);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return chart;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Generate a box for a function execution
|
|
40
|
-
*
|
|
41
|
-
* @param execution - The execution data
|
|
42
|
-
* @returns ASCII art box
|
|
43
|
-
*/
|
|
44
|
-
generateFunctionBox(execution) {
|
|
45
|
-
const { name, duration, isSlow, memoryUsage } = execution;
|
|
46
|
-
// Calculate padding for the function name
|
|
47
|
-
const nameLength = name.length;
|
|
48
|
-
const padding = Math.max(0, this._boxWidth - nameLength - 2);
|
|
49
|
-
const leftPadding = Math.floor(padding / 2);
|
|
50
|
-
const rightPadding = padding - leftPadding;
|
|
51
|
-
// Generate the box
|
|
52
|
-
let box = '';
|
|
53
|
-
// Top border
|
|
54
|
-
box += constants_1.BOX_CHARS.topLeft + constants_1.BOX_CHARS.horizontal.repeat(this._boxWidth) + constants_1.BOX_CHARS.topRight + '\n';
|
|
55
|
-
// Function name
|
|
56
|
-
box += constants_1.BOX_CHARS.vertical + ' '.repeat(leftPadding) + name + ' '.repeat(rightPadding) + constants_1.BOX_CHARS.vertical;
|
|
57
|
-
// Performance metrics
|
|
58
|
-
box += ` ${constants_1.PERFORMANCE_ICONS.timer} ${(0, timing_1.formatDuration)(duration)}`;
|
|
59
|
-
if (isSlow) {
|
|
60
|
-
box += ` ${constants_1.PERFORMANCE_ICONS.slow} SLOW`;
|
|
61
|
-
}
|
|
62
|
-
if (memoryUsage !== undefined) {
|
|
63
|
-
box += ` ${constants_1.PERFORMANCE_ICONS.memory} ${this.formatMemory(memoryUsage)}`;
|
|
64
|
-
}
|
|
65
|
-
box += '\n';
|
|
66
|
-
// Bottom border
|
|
67
|
-
box += constants_1.BOX_CHARS.bottomLeft + constants_1.BOX_CHARS.horizontal.repeat(this._boxWidth) + constants_1.BOX_CHARS.bottomRight + '\n';
|
|
68
|
-
return box;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Generate an arrow between function boxes
|
|
72
|
-
*
|
|
73
|
-
* @param levelDiff - Difference in nesting level
|
|
74
|
-
* @returns ASCII art arrow
|
|
75
|
-
*/
|
|
76
|
-
generateArrow(levelDiff) {
|
|
77
|
-
let arrow = '';
|
|
78
|
-
// Indent based on level difference
|
|
79
|
-
const indent = ' '.repeat(Math.max(0, levelDiff));
|
|
80
|
-
// Vertical line
|
|
81
|
-
arrow += indent + ' '.repeat(this._boxWidth / 2) + constants_1.BOX_CHARS.vertical + '\n';
|
|
82
|
-
// Arrow
|
|
83
|
-
arrow += indent + ' '.repeat(this._boxWidth / 2) + constants_1.BOX_CHARS.downArrow + '\n';
|
|
84
|
-
return arrow;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Format memory usage in a human-readable format
|
|
88
|
-
*
|
|
89
|
-
* @param bytes - Memory usage in bytes
|
|
90
|
-
* @returns Formatted memory usage
|
|
91
|
-
*/
|
|
92
|
-
formatMemory(bytes) {
|
|
93
|
-
const units = ['B', 'KB', 'MB', 'GB'];
|
|
94
|
-
let size = bytes;
|
|
95
|
-
let unitIndex = 0;
|
|
96
|
-
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
97
|
-
size /= 1024;
|
|
98
|
-
unitIndex++;
|
|
99
|
-
}
|
|
100
|
-
return `${size.toFixed(2)}${units[unitIndex]}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.AsciiArtGenerator = AsciiArtGenerator;
|
|
104
|
-
//# sourceMappingURL=ascii.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ascii.js","sourceRoot":"","sources":["../../src/formatters/ascii.ts"],"names":[],"mappings":";;;AAAA,iDAAiE;AACjE,4CAAiD;AAajD;;GAEG;AACH,MAAa,iBAAiB;IAG5B;;;;OAIG;IACH,YAAY,UAAiC,EAAE;;QAC7C,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI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,GAAG,IAAI,CAAC;QAE9E,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,YAAY,CAAC,KAAa;QAChC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,OAAO,IAAI,IAAI,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpD,IAAI,IAAI,IAAI,CAAC;YACb,SAAS,EAAE,CAAC;QACd,CAAC;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;IACjD,CAAC;CACF;AAtHD,8CAsHC"}
|
package/dist/formatters/cli.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { IFormatter, LogLevel, LogMeta } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* CLI formatter for console output
|
|
4
|
-
* Formats log entries with colors, icons, and indentation
|
|
5
|
-
*/
|
|
6
|
-
export declare class CliFormatter implements IFormatter {
|
|
7
|
-
private _colorEnabled;
|
|
8
|
-
private _indentSize;
|
|
9
|
-
/**
|
|
10
|
-
* Create a new CliFormatter instance
|
|
11
|
-
*
|
|
12
|
-
* @param options - Formatter options
|
|
13
|
-
*/
|
|
14
|
-
constructor(options?: {
|
|
15
|
-
colorEnabled?: boolean;
|
|
16
|
-
indentSize?: number;
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Format a log entry for CLI output
|
|
20
|
-
*
|
|
21
|
-
* @param level - The log level
|
|
22
|
-
* @param message - The log message
|
|
23
|
-
* @param args - Additional arguments
|
|
24
|
-
* @param meta - Metadata for the log entry
|
|
25
|
-
* @returns The formatted log entry
|
|
26
|
-
*/
|
|
27
|
-
format(level: LogLevel, message: string | object, args: any[], meta: LogMeta): string;
|
|
28
|
-
/**
|
|
29
|
-
* Format a timestamp
|
|
30
|
-
*
|
|
31
|
-
* @param date - The date to format
|
|
32
|
-
* @returns The formatted timestamp
|
|
33
|
-
*/
|
|
34
|
-
private formatTimestamp;
|
|
35
|
-
/**
|
|
36
|
-
* Format a log level
|
|
37
|
-
*
|
|
38
|
-
* @param level - The log level
|
|
39
|
-
* @returns The formatted log level
|
|
40
|
-
*/
|
|
41
|
-
private formatLevel;
|
|
42
|
-
/**
|
|
43
|
-
* Format a message and its arguments
|
|
44
|
-
*
|
|
45
|
-
* @param message - The message to format
|
|
46
|
-
* @param args - Additional arguments
|
|
47
|
-
* @returns The formatted message
|
|
48
|
-
*/
|
|
49
|
-
private formatMessage;
|
|
50
|
-
}
|
package/dist/formatters/cli.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CliFormatter = void 0;
|
|
4
|
-
const constants_1 = require("../core/constants");
|
|
5
|
-
const colors_1 = require("../utils/colors");
|
|
6
|
-
/**
|
|
7
|
-
* CLI formatter for console output
|
|
8
|
-
* Formats log entries with colors, icons, and indentation
|
|
9
|
-
*/
|
|
10
|
-
class CliFormatter {
|
|
11
|
-
/**
|
|
12
|
-
* Create a new CliFormatter instance
|
|
13
|
-
*
|
|
14
|
-
* @param options - Formatter options
|
|
15
|
-
*/
|
|
16
|
-
constructor(options = {}) {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
this._colorEnabled = (_a = options.colorEnabled) !== null && _a !== void 0 ? _a : (0, colors_1.supportsColor)();
|
|
19
|
-
this._indentSize = (_b = options.indentSize) !== null && _b !== void 0 ? _b : 2;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Format a log entry for CLI output
|
|
23
|
-
*
|
|
24
|
-
* @param level - The log level
|
|
25
|
-
* @param message - The log message
|
|
26
|
-
* @param args - Additional arguments
|
|
27
|
-
* @param meta - Metadata for the log entry
|
|
28
|
-
* @returns The formatted log entry
|
|
29
|
-
*/
|
|
30
|
-
format(level, message, args, meta) {
|
|
31
|
-
const timestamp = this.formatTimestamp(meta.timestamp);
|
|
32
|
-
const levelStr = this.formatLevel(level);
|
|
33
|
-
const indent = ' '.repeat(meta.indentLevel * this._indentSize);
|
|
34
|
-
const formattedMessage = this.formatMessage(message, args);
|
|
35
|
-
return `${timestamp} ${levelStr} ${indent}${formattedMessage}`;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Format a timestamp
|
|
39
|
-
*
|
|
40
|
-
* @param date - The date to format
|
|
41
|
-
* @returns The formatted timestamp
|
|
42
|
-
*/
|
|
43
|
-
formatTimestamp(date) {
|
|
44
|
-
const timeStr = date.toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
|
45
|
-
return this._colorEnabled ? (0, colors_1.dim)(`[${timeStr}]`) : `[${timeStr}]`;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Format a log level
|
|
49
|
-
*
|
|
50
|
-
* @param level - The log level
|
|
51
|
-
* @returns The formatted log level
|
|
52
|
-
*/
|
|
53
|
-
formatLevel(level) {
|
|
54
|
-
const icon = constants_1.LEVEL_ICONS[level];
|
|
55
|
-
const text = level.toUpperCase();
|
|
56
|
-
if (this._colorEnabled) {
|
|
57
|
-
return (0, colors_1.colorize)(`${icon} ${text}`, constants_1.LEVEL_COLORS[level]);
|
|
58
|
-
}
|
|
59
|
-
return `${icon} ${text}`;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Format a message and its arguments
|
|
63
|
-
*
|
|
64
|
-
* @param message - The message to format
|
|
65
|
-
* @param args - Additional arguments
|
|
66
|
-
* @returns The formatted message
|
|
67
|
-
*/
|
|
68
|
-
formatMessage(message, args) {
|
|
69
|
-
let formattedMessage;
|
|
70
|
-
if (typeof message === 'string') {
|
|
71
|
-
formattedMessage = message;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
try {
|
|
75
|
-
formattedMessage = JSON.stringify(message, null, 2);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
formattedMessage = String(message);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Format additional arguments
|
|
82
|
-
if (args.length > 0) {
|
|
83
|
-
const formattedArgs = args.map(arg => {
|
|
84
|
-
if (typeof arg === 'object' && arg !== null) {
|
|
85
|
-
try {
|
|
86
|
-
return JSON.stringify(arg, null, 2);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
return String(arg);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return String(arg);
|
|
93
|
-
}).join(' ');
|
|
94
|
-
formattedMessage = `${formattedMessage} ${formattedArgs}`;
|
|
95
|
-
}
|
|
96
|
-
return formattedMessage;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.CliFormatter = CliFormatter;
|
|
100
|
-
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/formatters/cli.ts"],"names":[],"mappings":";;;AACA,iDAA8D;AAC9D,4CAA+D;AAE/D;;;GAGG;AACH,MAAa,YAAY;IAIvB;;;;OAIG;IACH,YAAY,UAA2D,EAAE;;QACvE,IAAI,CAAC,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,mCAAI,IAAA,sBAAa,GAAE,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAe,EAAE,OAAwB,EAAE,IAAW,EAAE,IAAa;QACjF,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,MA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