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.
Files changed (268) hide show
  1. package/README.md +608 -253
  2. package/dist/__tests__/helpers/console.d.ts +9 -0
  3. package/dist/__tests__/helpers/console.js +25 -0
  4. package/dist/__tests__/helpers/console.js.map +1 -0
  5. package/dist/auto.d.ts +30 -0
  6. package/dist/auto.js +91 -0
  7. package/dist/auto.js.map +1 -0
  8. package/dist/browser.d.ts +52 -144
  9. package/dist/browser.js +112 -439
  10. package/dist/browser.js.map +1 -1
  11. package/dist/cli.d.ts +68 -0
  12. package/dist/cli.js +528 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/core/allocations.d.ts +38 -0
  15. package/dist/core/allocations.js +85 -0
  16. package/dist/core/allocations.js.map +1 -0
  17. package/dist/core/cpu-profile.d.ts +84 -0
  18. package/dist/core/cpu-profile.js +181 -0
  19. package/dist/core/cpu-profile.js.map +1 -0
  20. package/dist/core/env.d.ts +10 -0
  21. package/dist/core/env.js +40 -0
  22. package/dist/core/env.js.map +1 -0
  23. package/dist/core/event-loop.d.ts +30 -0
  24. package/dist/core/event-loop.js +43 -0
  25. package/dist/core/event-loop.js.map +1 -0
  26. package/dist/core/explain.d.ts +48 -0
  27. package/dist/core/explain.js +236 -0
  28. package/dist/core/explain.js.map +1 -0
  29. package/dist/core/exporters.d.ts +111 -0
  30. package/dist/core/exporters.js +236 -0
  31. package/dist/core/exporters.js.map +1 -0
  32. package/dist/core/index.d.ts +9 -3
  33. package/dist/core/index.js +9 -3
  34. package/dist/core/index.js.map +1 -1
  35. package/dist/core/optimized-performance-monitor.d.ts +180 -26
  36. package/dist/core/optimized-performance-monitor.js +687 -175
  37. package/dist/core/optimized-performance-monitor.js.map +1 -1
  38. package/dist/core/prometheus.d.ts +36 -0
  39. package/dist/core/prometheus.js +93 -0
  40. package/dist/core/prometheus.js.map +1 -0
  41. package/dist/core/records.d.ts +97 -0
  42. package/dist/core/records.js +87 -0
  43. package/dist/core/records.js.map +1 -0
  44. package/dist/core/stats.d.ts +45 -0
  45. package/dist/core/stats.js +136 -0
  46. package/dist/core/stats.js.map +1 -0
  47. package/dist/core/timeline.d.ts +28 -0
  48. package/dist/core/timeline.js +65 -0
  49. package/dist/core/timeline.js.map +1 -0
  50. package/dist/drivers.d.ts +51 -0
  51. package/dist/drivers.js +205 -0
  52. package/dist/drivers.js.map +1 -0
  53. package/dist/esm/auto.d.ts +30 -0
  54. package/dist/esm/auto.js +87 -0
  55. package/dist/esm/auto.js.map +1 -0
  56. package/dist/esm/browser.d.ts +52 -144
  57. package/dist/esm/browser.js +101 -445
  58. package/dist/esm/browser.js.map +1 -1
  59. package/dist/esm/cli.d.ts +68 -0
  60. package/dist/esm/cli.js +520 -0
  61. package/dist/esm/cli.js.map +1 -0
  62. package/dist/esm/core/allocations.d.ts +38 -0
  63. package/dist/esm/core/allocations.js +82 -0
  64. package/dist/esm/core/allocations.js.map +1 -0
  65. package/dist/esm/core/cpu-profile.d.ts +84 -0
  66. package/dist/esm/core/cpu-profile.js +176 -0
  67. package/dist/esm/core/cpu-profile.js.map +1 -0
  68. package/dist/esm/core/env.d.ts +10 -0
  69. package/dist/esm/core/env.js +35 -0
  70. package/dist/esm/core/env.js.map +1 -0
  71. package/dist/esm/core/event-loop.d.ts +30 -0
  72. package/dist/esm/core/event-loop.js +40 -0
  73. package/dist/esm/core/event-loop.js.map +1 -0
  74. package/dist/esm/core/explain.d.ts +48 -0
  75. package/dist/esm/core/explain.js +232 -0
  76. package/dist/esm/core/explain.js.map +1 -0
  77. package/dist/esm/core/exporters.d.ts +111 -0
  78. package/dist/esm/core/exporters.js +229 -0
  79. package/dist/esm/core/exporters.js.map +1 -0
  80. package/dist/esm/core/index.d.ts +10 -4
  81. package/dist/esm/core/index.js +10 -4
  82. package/dist/esm/core/index.js.map +1 -1
  83. package/dist/esm/core/optimized-performance-monitor.d.ts +180 -26
  84. package/dist/esm/core/optimized-performance-monitor.js +685 -173
  85. package/dist/esm/core/optimized-performance-monitor.js.map +1 -1
  86. package/dist/esm/core/prometheus.d.ts +36 -0
  87. package/dist/esm/core/prometheus.js +89 -0
  88. package/dist/esm/core/prometheus.js.map +1 -0
  89. package/dist/esm/core/records.d.ts +97 -0
  90. package/dist/esm/core/records.js +82 -0
  91. package/dist/esm/core/records.js.map +1 -0
  92. package/dist/esm/core/stats.d.ts +45 -0
  93. package/dist/esm/core/stats.js +131 -0
  94. package/dist/esm/core/stats.js.map +1 -0
  95. package/dist/esm/core/timeline.d.ts +28 -0
  96. package/dist/esm/core/timeline.js +62 -0
  97. package/dist/esm/core/timeline.js.map +1 -0
  98. package/dist/esm/drivers.d.ts +51 -0
  99. package/dist/esm/drivers.js +197 -0
  100. package/dist/esm/drivers.js.map +1 -0
  101. package/dist/esm/index.d.ts +13 -5
  102. package/dist/esm/index.js +21 -17
  103. package/dist/esm/index.js.map +1 -1
  104. package/dist/esm/instrument.d.ts +88 -0
  105. package/dist/esm/instrument.js +274 -0
  106. package/dist/esm/instrument.js.map +1 -0
  107. package/dist/esm/integrations.d.ts +70 -0
  108. package/dist/esm/integrations.js +197 -0
  109. package/dist/esm/integrations.js.map +1 -0
  110. package/dist/esm/node-builtins.d.ts +1 -0
  111. package/dist/esm/node-builtins.js +32 -0
  112. package/dist/esm/node-builtins.js.map +1 -0
  113. package/dist/esm/package.json +3 -0
  114. package/dist/esm/register.d.ts +20 -0
  115. package/dist/esm/register.js +98 -0
  116. package/dist/esm/register.js.map +1 -0
  117. package/dist/esm/report-html.d.ts +11 -0
  118. package/dist/esm/report-html.js +106 -0
  119. package/dist/esm/report-html.js.map +1 -0
  120. package/dist/esm/types/index.d.ts +4 -80
  121. package/dist/esm/types/index.js +1 -2
  122. package/dist/esm/types/index.js.map +1 -1
  123. package/dist/esm/types/options.d.ts +72 -0
  124. package/dist/esm/types/options.js +2 -0
  125. package/dist/esm/types/options.js.map +1 -0
  126. package/dist/esm/watch.d.ts +17 -0
  127. package/dist/esm/watch.js +87 -0
  128. package/dist/esm/watch.js.map +1 -0
  129. package/dist/index.d.ts +10 -2
  130. package/dist/index.js +26 -29
  131. package/dist/index.js.map +1 -1
  132. package/dist/instrument.d.ts +88 -0
  133. package/dist/instrument.js +282 -0
  134. package/dist/instrument.js.map +1 -0
  135. package/dist/integrations.d.ts +70 -0
  136. package/dist/integrations.js +205 -0
  137. package/dist/integrations.js.map +1 -0
  138. package/dist/node-builtins.d.ts +1 -0
  139. package/dist/node-builtins.js +67 -0
  140. package/dist/node-builtins.js.map +1 -0
  141. package/dist/register.d.ts +20 -0
  142. package/dist/register.js +103 -0
  143. package/dist/register.js.map +1 -0
  144. package/dist/report-html.d.ts +11 -0
  145. package/dist/report-html.js +109 -0
  146. package/dist/report-html.js.map +1 -0
  147. package/dist/traceperf.browser.js +1910 -0
  148. package/dist/traceperf.browser.min.js +6 -0
  149. package/dist/types/index.d.ts +4 -80
  150. package/dist/types/index.js +1 -2
  151. package/dist/types/index.js.map +1 -1
  152. package/dist/types/options.d.ts +72 -0
  153. package/dist/types/{config.js → options.js} +1 -1
  154. package/dist/types/options.js.map +1 -0
  155. package/dist/watch.d.ts +17 -0
  156. package/dist/watch.js +90 -0
  157. package/dist/watch.js.map +1 -0
  158. package/package.json +99 -19
  159. package/dist/core/config.d.ts +0 -77
  160. package/dist/core/config.js +0 -116
  161. package/dist/core/config.js.map +0 -1
  162. package/dist/core/constants.d.ts +0 -78
  163. package/dist/core/constants.js +0 -109
  164. package/dist/core/constants.js.map +0 -1
  165. package/dist/core/logger.d.ts +0 -97
  166. package/dist/core/logger.js +0 -186
  167. package/dist/core/logger.js.map +0 -1
  168. package/dist/esm/core/config.d.ts +0 -77
  169. package/dist/esm/core/config.js +0 -112
  170. package/dist/esm/core/config.js.map +0 -1
  171. package/dist/esm/core/constants.d.ts +0 -78
  172. package/dist/esm/core/constants.js +0 -106
  173. package/dist/esm/core/constants.js.map +0 -1
  174. package/dist/esm/core/logger.d.ts +0 -97
  175. package/dist/esm/core/logger.js +0 -182
  176. package/dist/esm/core/logger.js.map +0 -1
  177. package/dist/esm/formatters/ascii.d.ts +0 -52
  178. package/dist/esm/formatters/ascii.js +0 -100
  179. package/dist/esm/formatters/ascii.js.map +0 -1
  180. package/dist/esm/formatters/cli.d.ts +0 -50
  181. package/dist/esm/formatters/cli.js +0 -96
  182. package/dist/esm/formatters/cli.js.map +0 -1
  183. package/dist/esm/formatters/index.d.ts +0 -3
  184. package/dist/esm/formatters/index.js +0 -4
  185. package/dist/esm/formatters/index.js.map +0 -1
  186. package/dist/esm/formatters/json.d.ts +0 -45
  187. package/dist/esm/formatters/json.js +0 -85
  188. package/dist/esm/formatters/json.js.map +0 -1
  189. package/dist/esm/trackers/execution.d.ts +0 -101
  190. package/dist/esm/trackers/execution.js +0 -226
  191. package/dist/esm/trackers/execution.js.map +0 -1
  192. package/dist/esm/trackers/index.d.ts +0 -2
  193. package/dist/esm/trackers/index.js +0 -3
  194. package/dist/esm/trackers/index.js.map +0 -1
  195. package/dist/esm/trackers/performance.d.ts +0 -68
  196. package/dist/esm/trackers/performance.js +0 -112
  197. package/dist/esm/trackers/performance.js.map +0 -1
  198. package/dist/esm/types/config.d.ts +0 -142
  199. package/dist/esm/types/config.js +0 -2
  200. package/dist/esm/types/config.js.map +0 -1
  201. package/dist/esm/types/logger.d.ts +0 -147
  202. package/dist/esm/types/logger.js +0 -2
  203. package/dist/esm/types/logger.js.map +0 -1
  204. package/dist/esm/utils/colors.d.ts +0 -87
  205. package/dist/esm/utils/colors.js +0 -146
  206. package/dist/esm/utils/colors.js.map +0 -1
  207. package/dist/esm/utils/index.d.ts +0 -3
  208. package/dist/esm/utils/index.js +0 -4
  209. package/dist/esm/utils/index.js.map +0 -1
  210. package/dist/esm/utils/proxy-tracker.d.ts +0 -68
  211. package/dist/esm/utils/proxy-tracker.js +0 -127
  212. package/dist/esm/utils/proxy-tracker.js.map +0 -1
  213. package/dist/esm/utils/stack.d.ts +0 -63
  214. package/dist/esm/utils/stack.js +0 -110
  215. package/dist/esm/utils/stack.js.map +0 -1
  216. package/dist/esm/utils/string.d.ts +0 -29
  217. package/dist/esm/utils/string.js +0 -45
  218. package/dist/esm/utils/string.js.map +0 -1
  219. package/dist/esm/utils/timing.d.ts +0 -65
  220. package/dist/esm/utils/timing.js +0 -99
  221. package/dist/esm/utils/timing.js.map +0 -1
  222. package/dist/formatters/ascii.d.ts +0 -52
  223. package/dist/formatters/ascii.js +0 -104
  224. package/dist/formatters/ascii.js.map +0 -1
  225. package/dist/formatters/cli.d.ts +0 -50
  226. package/dist/formatters/cli.js +0 -100
  227. package/dist/formatters/cli.js.map +0 -1
  228. package/dist/formatters/index.d.ts +0 -3
  229. package/dist/formatters/index.js +0 -20
  230. package/dist/formatters/index.js.map +0 -1
  231. package/dist/formatters/json.d.ts +0 -45
  232. package/dist/formatters/json.js +0 -89
  233. package/dist/formatters/json.js.map +0 -1
  234. package/dist/trackers/execution.d.ts +0 -101
  235. package/dist/trackers/execution.js +0 -230
  236. package/dist/trackers/execution.js.map +0 -1
  237. package/dist/trackers/index.d.ts +0 -2
  238. package/dist/trackers/index.js +0 -19
  239. package/dist/trackers/index.js.map +0 -1
  240. package/dist/trackers/performance.d.ts +0 -68
  241. package/dist/trackers/performance.js +0 -116
  242. package/dist/trackers/performance.js.map +0 -1
  243. package/dist/types/config.d.ts +0 -142
  244. package/dist/types/config.js.map +0 -1
  245. package/dist/types/logger.d.ts +0 -147
  246. package/dist/types/logger.js +0 -3
  247. package/dist/types/logger.js.map +0 -1
  248. package/dist/types.d.ts +0 -65
  249. package/dist/types.js +0 -6
  250. package/dist/types.js.map +0 -1
  251. package/dist/utils/colors.d.ts +0 -87
  252. package/dist/utils/colors.js +0 -160
  253. package/dist/utils/colors.js.map +0 -1
  254. package/dist/utils/index.d.ts +0 -3
  255. package/dist/utils/index.js +0 -20
  256. package/dist/utils/index.js.map +0 -1
  257. package/dist/utils/proxy-tracker.d.ts +0 -68
  258. package/dist/utils/proxy-tracker.js +0 -131
  259. package/dist/utils/proxy-tracker.js.map +0 -1
  260. package/dist/utils/stack.d.ts +0 -63
  261. package/dist/utils/stack.js +0 -116
  262. package/dist/utils/stack.js.map +0 -1
  263. package/dist/utils/string.d.ts +0 -29
  264. package/dist/utils/string.js +0 -50
  265. package/dist/utils/string.js.map +0 -1
  266. package/dist/utils/timing.d.ts +0 -65
  267. package/dist/utils/timing.js +0 -106
  268. package/dist/utils/timing.js.map +0 -1
@@ -1,100 +0,0 @@
1
- import { BOX_CHARS, PERFORMANCE_ICONS } from '../core/constants';
2
- import { formatDuration } from '../utils/timing';
3
- /**
4
- * ASCII art generator for execution flow charts
5
- */
6
- export class AsciiArtGenerator {
7
- /**
8
- * Create a new AsciiArtGenerator instance
9
- *
10
- * @param options - Generator options
11
- */
12
- constructor(options = {}) {
13
- var _a;
14
- this._boxWidth = (_a = options.boxWidth) !== null && _a !== void 0 ? _a : 30;
15
- }
16
- /**
17
- * Generate a flow chart for a sequence of function executions
18
- *
19
- * @param executions - Array of execution data
20
- * @returns ASCII art flow chart
21
- */
22
- generateFlowChart(executions) {
23
- let chart = '';
24
- for (let i = 0; i < executions.length; i++) {
25
- const execution = executions[i];
26
- // Generate box for function
27
- chart += this.generateFunctionBox(execution);
28
- // Add arrow to next function if not the last one
29
- if (i < executions.length - 1) {
30
- chart += this.generateArrow(executions[i + 1].level - execution.level);
31
- }
32
- }
33
- return chart;
34
- }
35
- /**
36
- * Generate a box for a function execution
37
- *
38
- * @param execution - The execution data
39
- * @returns ASCII art box
40
- */
41
- generateFunctionBox(execution) {
42
- const { name, duration, isSlow, memoryUsage } = execution;
43
- // Calculate padding for the function name
44
- const nameLength = name.length;
45
- const padding = Math.max(0, this._boxWidth - nameLength - 2);
46
- const leftPadding = Math.floor(padding / 2);
47
- const rightPadding = padding - leftPadding;
48
- // Generate the box
49
- let box = '';
50
- // Top border
51
- box += BOX_CHARS.topLeft + BOX_CHARS.horizontal.repeat(this._boxWidth) + BOX_CHARS.topRight + '\n';
52
- // Function name
53
- box += BOX_CHARS.vertical + ' '.repeat(leftPadding) + name + ' '.repeat(rightPadding) + BOX_CHARS.vertical;
54
- // Performance metrics
55
- box += ` ${PERFORMANCE_ICONS.timer} ${formatDuration(duration)}`;
56
- if (isSlow) {
57
- box += ` ${PERFORMANCE_ICONS.slow} SLOW`;
58
- }
59
- if (memoryUsage !== undefined) {
60
- box += ` ${PERFORMANCE_ICONS.memory} ${this.formatMemory(memoryUsage)}`;
61
- }
62
- box += '\n';
63
- // Bottom border
64
- box += BOX_CHARS.bottomLeft + BOX_CHARS.horizontal.repeat(this._boxWidth) + BOX_CHARS.bottomRight + '\n';
65
- return box;
66
- }
67
- /**
68
- * Generate an arrow between function boxes
69
- *
70
- * @param levelDiff - Difference in nesting level
71
- * @returns ASCII art arrow
72
- */
73
- generateArrow(levelDiff) {
74
- let arrow = '';
75
- // Indent based on level difference
76
- const indent = ' '.repeat(Math.max(0, levelDiff));
77
- // Vertical line
78
- arrow += indent + ' '.repeat(this._boxWidth / 2) + BOX_CHARS.vertical + '\n';
79
- // Arrow
80
- arrow += indent + ' '.repeat(this._boxWidth / 2) + BOX_CHARS.downArrow + '\n';
81
- return arrow;
82
- }
83
- /**
84
- * Format memory usage in a human-readable format
85
- *
86
- * @param bytes - Memory usage in bytes
87
- * @returns Formatted memory usage
88
- */
89
- formatMemory(bytes) {
90
- const units = ['B', 'KB', 'MB', 'GB'];
91
- let size = bytes;
92
- let unitIndex = 0;
93
- while (size >= 1024 && unitIndex < units.length - 1) {
94
- size /= 1024;
95
- unitIndex++;
96
- }
97
- return `${size.toFixed(2)}${units[unitIndex]}`;
98
- }
99
- }
100
- //# sourceMappingURL=ascii.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ascii.js","sourceRoot":"","sources":["../../../src/formatters/ascii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO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AC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE7E,QAAQ;QACR,KAAK,IAAI,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,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"}
@@ -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
- }
@@ -1,96 +0,0 @@
1
- import { LEVEL_COLORS, LEVEL_ICONS } from '../core/constants';
2
- import { colorize, dim, supportsColor } from '../utils/colors';
3
- /**
4
- * CLI formatter for console output
5
- * Formats log entries with colors, icons, and indentation
6
- */
7
- export class CliFormatter {
8
- /**
9
- * Create a new CliFormatter instance
10
- *
11
- * @param options - Formatter options
12
- */
13
- constructor(options = {}) {
14
- var _a, _b;
15
- this._colorEnabled = (_a = options.colorEnabled) !== null && _a !== void 0 ? _a : supportsColor();
16
- this._indentSize = (_b = options.indentSize) !== null && _b !== void 0 ? _b : 2;
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, message, args, meta) {
28
- const timestamp = this.formatTimestamp(meta.timestamp);
29
- const levelStr = this.formatLevel(level);
30
- const indent = ' '.repeat(meta.indentLevel * this._indentSize);
31
- const formattedMessage = this.formatMessage(message, args);
32
- return `${timestamp} ${levelStr} ${indent}${formattedMessage}`;
33
- }
34
- /**
35
- * Format a timestamp
36
- *
37
- * @param date - The date to format
38
- * @returns The formatted timestamp
39
- */
40
- formatTimestamp(date) {
41
- const timeStr = date.toISOString().replace(/T/, ' ').replace(/\..+/, '');
42
- return this._colorEnabled ? dim(`[${timeStr}]`) : `[${timeStr}]`;
43
- }
44
- /**
45
- * Format a log level
46
- *
47
- * @param level - The log level
48
- * @returns The formatted log level
49
- */
50
- formatLevel(level) {
51
- const icon = LEVEL_ICONS[level];
52
- const text = level.toUpperCase();
53
- if (this._colorEnabled) {
54
- return colorize(`${icon} ${text}`, LEVEL_COLORS[level]);
55
- }
56
- return `${icon} ${text}`;
57
- }
58
- /**
59
- * Format a message and its arguments
60
- *
61
- * @param message - The message to format
62
- * @param args - Additional arguments
63
- * @returns The formatted message
64
- */
65
- formatMessage(message, args) {
66
- let formattedMessage;
67
- if (typeof message === 'string') {
68
- formattedMessage = message;
69
- }
70
- else {
71
- try {
72
- formattedMessage = JSON.stringify(message, null, 2);
73
- }
74
- catch (error) {
75
- formattedMessage = String(message);
76
- }
77
- }
78
- // Format additional arguments
79
- if (args.length > 0) {
80
- const formattedArgs = args.map(arg => {
81
- if (typeof arg === 'object' && arg !== null) {
82
- try {
83
- return JSON.stringify(arg, null, 2);
84
- }
85
- catch (error) {
86
- return String(arg);
87
- }
88
- }
89
- return String(arg);
90
- }).join(' ');
91
- formattedMessage = `${formattedMessage} ${formattedArgs}`;
92
- }
93
- return formattedMessage;
94
- }
95
- }
96
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/formatters/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;;OAIG;IACH,YAAY,UAA2D,EAAE;;QACvE,IAAI,CAAC,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,mCAAI,aAAa,EAAE,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;QACv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GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACtD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,8BAA8B;QAC9B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;oBAC5C,IAAI,CAAC;wBACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;oBACtC,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;oBACrB,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEb,gBAAgB,GAAG,GAAG,gBAAgB,IAAI,aAAa,EAAE,CAAC;QAC5D,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF"}
@@ -1,3 +0,0 @@
1
- export * from './cli';
2
- export * from './json';
3
- export * from './ascii';
@@ -1,4 +0,0 @@
1
- export * from './cli';
2
- export * from './json';
3
- export * from './ascii';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatters/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
@@ -1,45 +0,0 @@
1
- import { IFormatter, LogLevel, LogMeta } from '../types';
2
- /**
3
- * JSON formatter for structured output
4
- * Formats log entries as JSON objects
5
- */
6
- export declare class JsonFormatter implements IFormatter {
7
- /**
8
- * Format a log entry as JSON
9
- *
10
- * @param level - The log level
11
- * @param message - The log message
12
- * @param args - Additional arguments
13
- * @param meta - Metadata for the log entry
14
- * @returns The formatted log entry as a JSON string
15
- */
16
- format(level: LogLevel, message: string | object, args: any[], meta: LogMeta): string;
17
- /**
18
- * Format a message for JSON output
19
- *
20
- * @param message - The message to format
21
- * @returns The formatted message
22
- */
23
- private formatMessage;
24
- /**
25
- * Format arguments for JSON output
26
- *
27
- * @param args - The arguments to format
28
- * @returns The formatted arguments
29
- */
30
- private formatArgs;
31
- /**
32
- * Sanitize an object for JSON serialization
33
- *
34
- * @param obj - The object to sanitize
35
- * @returns A sanitized version of the object
36
- */
37
- private sanitizeObject;
38
- /**
39
- * Extract additional metadata from the log meta object
40
- *
41
- * @param meta - The log metadata
42
- * @returns Additional metadata as an object
43
- */
44
- private extractExtraMeta;
45
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * JSON formatter for structured output
3
- * Formats log entries as JSON objects
4
- */
5
- export class JsonFormatter {
6
- /**
7
- * Format a log entry as JSON
8
- *
9
- * @param level - The log level
10
- * @param message - The log message
11
- * @param args - Additional arguments
12
- * @param meta - Metadata for the log entry
13
- * @returns The formatted log entry as a JSON string
14
- */
15
- format(level, message, args, meta) {
16
- const logEntry = {
17
- timestamp: meta.timestamp.toISOString(),
18
- level,
19
- indentLevel: meta.indentLevel,
20
- message: this.formatMessage(message),
21
- args: this.formatArgs(args),
22
- ...this.extractExtraMeta(meta),
23
- };
24
- return JSON.stringify(logEntry);
25
- }
26
- /**
27
- * Format a message for JSON output
28
- *
29
- * @param message - The message to format
30
- * @returns The formatted message
31
- */
32
- formatMessage(message) {
33
- if (typeof message === 'string') {
34
- return message;
35
- }
36
- return this.sanitizeObject(message);
37
- }
38
- /**
39
- * Format arguments for JSON output
40
- *
41
- * @param args - The arguments to format
42
- * @returns The formatted arguments
43
- */
44
- formatArgs(args) {
45
- return args.map(arg => {
46
- if (typeof arg === 'object' && arg !== null) {
47
- return this.sanitizeObject(arg);
48
- }
49
- return arg;
50
- });
51
- }
52
- /**
53
- * Sanitize an object for JSON serialization
54
- *
55
- * @param obj - The object to sanitize
56
- * @returns A sanitized version of the object
57
- */
58
- sanitizeObject(obj) {
59
- try {
60
- // Use JSON.parse(JSON.stringify()) to remove non-serializable values
61
- return JSON.parse(JSON.stringify(obj));
62
- }
63
- catch (error) {
64
- // If serialization fails, return a simplified object
65
- return { value: String(obj) };
66
- }
67
- }
68
- /**
69
- * Extract additional metadata from the log meta object
70
- *
71
- * @param meta - The log metadata
72
- * @returns Additional metadata as an object
73
- */
74
- extractExtraMeta(meta) {
75
- const result = {};
76
- // Copy all properties except the standard ones
77
- Object.keys(meta).forEach(key => {
78
- if (!['timestamp', 'level', 'indentLevel'].includes(key)) {
79
- result[key] = meta[key];
80
- }
81
- });
82
- return result;
83
- }
84
- }
85
- //# sourceMappingURL=json.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/formatters/json.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAe,EAAE,OAAwB,EAAE,IAAW,EAAE,IAAa;QACjF,MAAM,QAAQ,GAAG;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,KAAK;YACL,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAC3B,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;SAC/B,CAAC;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACK,aAAa,CAAC,OAAwB;QAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACK,UAAU,CAAC,IAAW;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACpB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,GAAW;QAChC,IAAI,CAAC;YACH,qEAAqE;YACrE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qDAAqD;YACrD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACK,gBAAgB,CAAC,IAAa;QACpC,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,+CAA+C;QAC/C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9B,IAAI,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -1,101 +0,0 @@
1
- import { IExecutionTracker, ITrackOptions } from '../types';
2
- /**
3
- * A record of a function execution
4
- */
5
- export interface ExecutionRecord {
6
- name: string;
7
- duration: number;
8
- startTime: [number, number];
9
- endTime?: [number, number];
10
- isSlow: boolean;
11
- level: number;
12
- memoryUsage?: number;
13
- memoryReleased?: number;
14
- children: ExecutionRecord[];
15
- parent?: ExecutionRecord;
16
- }
17
- /**
18
- * Execution tracker for performance monitoring
19
- */
20
- export declare class ExecutionTracker implements IExecutionTracker {
21
- private _executions;
22
- private _currentExecution;
23
- private _defaultThreshold;
24
- private _callStack;
25
- private _globalScope;
26
- private _trackedFunctions;
27
- /**
28
- * Constructor
29
- *
30
- * @param options - Options for execution tracking
31
- */
32
- constructor(options?: {
33
- defaultThreshold?: number;
34
- });
35
- /**
36
- * Track the execution of a function
37
- *
38
- * @param fn - The function to track
39
- * @param options - Options for tracking
40
- * @returns The return value of the tracked function
41
- */
42
- track<T>(fn: () => T, options?: ITrackOptions): T;
43
- /**
44
- * Create a trackable version of a function
45
- *
46
- * This is a helper method to create a tracked version of a function
47
- * that can be used for nested function tracking.
48
- *
49
- * @param fn - The function to make trackable
50
- * @param options - Options for tracking
51
- * @returns A tracked version of the function
52
- */
53
- createTrackable<T extends (...args: any[]) => any>(fn: T, options?: Omit<ITrackOptions, 'label'> & {
54
- label?: string;
55
- }): (...args: Parameters<T>) => ReturnType<T>;
56
- /**
57
- * Get all execution records
58
- *
59
- * @returns A list of execution records
60
- */
61
- getExecutions(): ExecutionRecord[];
62
- /**
63
- * Generate a human-friendly memory size string
64
- *
65
- * @param bytes - The size in bytes
66
- * @returns A formatted string
67
- */
68
- formatMemorySize(bytes: number): string;
69
- /**
70
- * Get the current call stack
71
- *
72
- * @returns The current call stack
73
- */
74
- getCallStack(): string[];
75
- /**
76
- * Generate a visual representation of the execution flow
77
- *
78
- * @returns ASCII flow chart of the execution
79
- */
80
- generateFlowChart(): string;
81
- /**
82
- * Recursively print an execution tree
83
- *
84
- * @param execution - The root execution
85
- * @param result - The output string
86
- * @returns The updated result string
87
- */
88
- private printExecutionTree;
89
- /**
90
- * Print a single execution with appropriate formatting
91
- *
92
- * @param execution - The execution to print
93
- * @param result - The result string to append to
94
- * @returns The updated result string
95
- */
96
- private printSingleExecution;
97
- /**
98
- * Clear all execution records
99
- */
100
- clear(): void;
101
- }