@mks2508/better-logger 5.0.1 → 5.0.2

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 (310) hide show
  1. package/dist/Logger.d.ts +976 -0
  2. package/dist/Logger.d.ts.map +1 -0
  3. package/dist/ScopedLogger.d.ts +74 -0
  4. package/dist/ScopedLogger.d.ts.map +1 -0
  5. package/dist/chunks/Logger-CKqzXDh3.js +2 -0
  6. package/dist/chunks/Logger-CKqzXDh3.js.map +1 -0
  7. package/dist/chunks/Logger-D_vuKP4l.js +4511 -0
  8. package/dist/chunks/Logger-D_vuKP4l.js.map +1 -0
  9. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  10. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  11. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  12. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  13. package/dist/chunks/cli-module-B-njrTWb.js +2 -0
  14. package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
  15. package/dist/chunks/cli-module-Cx7qotPY.js +390 -0
  16. package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
  17. package/dist/chunks/color-converter-CCSQRztd.js +2 -0
  18. package/dist/chunks/color-converter-CCSQRztd.js.map +1 -0
  19. package/dist/chunks/color-converter-_Xdmsy7E.js +462 -0
  20. package/dist/chunks/color-converter-_Xdmsy7E.js.map +1 -0
  21. package/dist/chunks/environment-C1xxvc8l.js +1127 -0
  22. package/dist/chunks/environment-C1xxvc8l.js.map +1 -0
  23. package/dist/chunks/environment-Cprkw3g9.js +4 -0
  24. package/dist/chunks/environment-Cprkw3g9.js.map +1 -0
  25. package/dist/chunks/formatting-DMJxYq9o.js +380 -0
  26. package/dist/chunks/formatting-DMJxYq9o.js.map +1 -0
  27. package/dist/chunks/formatting-DpKxCsXq.js +2 -0
  28. package/dist/chunks/formatting-DpKxCsXq.js.map +1 -0
  29. package/dist/cli/CommandProcessor.d.ts +100 -0
  30. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  31. package/dist/cli/commands/ConfigCommand.d.ts +14 -0
  32. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  33. package/dist/cli/commands/ExportCommand.d.ts +48 -0
  34. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/HistoryCommand.d.ts +47 -0
  36. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  37. package/dist/cli/commands/StatusCommand.d.ts +30 -0
  38. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  39. package/dist/cli/commands/ThemeCommand.d.ts +30 -0
  40. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  41. package/dist/cli/help.d.ts +12 -0
  42. package/dist/cli/help.d.ts.map +1 -0
  43. package/dist/cli/index.d.ts +15 -0
  44. package/dist/cli/index.d.ts.map +1 -0
  45. package/{src/cli-module.ts → dist/cli-module.d.ts} +2 -8
  46. package/dist/cli-module.d.ts.map +1 -0
  47. package/dist/cli-primitives/box.d.ts +11 -0
  48. package/dist/cli-primitives/box.d.ts.map +1 -0
  49. package/dist/cli-primitives/cli-table.d.ts +11 -0
  50. package/dist/cli-primitives/cli-table.d.ts.map +1 -0
  51. package/dist/cli-primitives/divider.d.ts +11 -0
  52. package/dist/cli-primitives/divider.d.ts.map +1 -0
  53. package/dist/cli-primitives/header.d.ts +12 -0
  54. package/dist/cli-primitives/header.d.ts.map +1 -0
  55. package/{src/cli-primitives/index.ts → dist/cli-primitives/index.d.ts} +1 -1
  56. package/dist/cli-primitives/index.d.ts.map +1 -0
  57. package/dist/cli-primitives/server-fallback.d.ts +25 -0
  58. package/dist/cli-primitives/server-fallback.d.ts.map +1 -0
  59. package/dist/cli-primitives/spinner.d.ts +47 -0
  60. package/dist/cli-primitives/spinner.d.ts.map +1 -0
  61. package/dist/cli-primitives/step.d.ts +11 -0
  62. package/dist/cli-primitives/step.d.ts.map +1 -0
  63. package/dist/cli.cjs +2 -0
  64. package/dist/cli.cjs.map +1 -0
  65. package/dist/cli.js +12 -0
  66. package/dist/cli.js.map +1 -0
  67. package/dist/constants.d.ts +235 -0
  68. package/dist/constants.d.ts.map +1 -0
  69. package/dist/core.cjs +2 -0
  70. package/dist/core.cjs.map +1 -0
  71. package/dist/core.d.ts +127 -0
  72. package/dist/core.d.ts.map +1 -0
  73. package/dist/core.js +291 -0
  74. package/dist/core.js.map +1 -0
  75. package/dist/example.d.ts +18 -0
  76. package/dist/example.d.ts.map +1 -0
  77. package/dist/exports-module.d.ts +196 -0
  78. package/dist/exports-module.d.ts.map +1 -0
  79. package/dist/exports.cjs +2 -0
  80. package/dist/exports.cjs.map +1 -0
  81. package/dist/exports.js +238 -0
  82. package/dist/exports.js.map +1 -0
  83. package/dist/handlers/AnalyticsLogHandler.d.ts +8 -0
  84. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  85. package/dist/handlers/ExportLogHandler.d.ts +100 -0
  86. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  87. package/dist/handlers/FileLogHandler.d.ts +33 -0
  88. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  89. package/dist/handlers/RemoteLogHandler.d.ts +11 -0
  90. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  91. package/{src/handlers/index.ts → dist/handlers/index.d.ts} +2 -2
  92. package/dist/handlers/index.d.ts.map +1 -0
  93. package/dist/hooks/HookManager.d.ts +21 -0
  94. package/dist/hooks/HookManager.d.ts.map +1 -0
  95. package/{src/hooks/index.ts → dist/hooks/index.d.ts} +1 -0
  96. package/dist/hooks/index.d.ts.map +1 -0
  97. package/dist/index.cjs +2 -0
  98. package/dist/index.cjs.map +1 -0
  99. package/dist/index.d.ts +161 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +627 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/main.d.ts +2 -0
  104. package/dist/main.d.ts.map +1 -0
  105. package/dist/serializers/SerializerRegistry.d.ts +16 -0
  106. package/dist/serializers/SerializerRegistry.d.ts.map +1 -0
  107. package/{src/serializers/index.ts → dist/serializers/index.d.ts} +1 -0
  108. package/dist/serializers/index.d.ts.map +1 -0
  109. package/dist/styling/LogStyleBuilder.d.ts +146 -0
  110. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  111. package/dist/styling/SemanticStyles.d.ts +178 -0
  112. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  113. package/dist/styling/SmartPresets.d.ts +22 -0
  114. package/dist/styling/SmartPresets.d.ts.map +1 -0
  115. package/dist/styling/StyleBuilder.d.ts +140 -0
  116. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  117. package/dist/styling/StyleCache.d.ts +42 -0
  118. package/dist/styling/StyleCache.d.ts.map +1 -0
  119. package/dist/styling/banners.d.ts +42 -0
  120. package/dist/styling/banners.d.ts.map +1 -0
  121. package/dist/styling/index.d.ts +10 -0
  122. package/dist/styling/index.d.ts.map +1 -0
  123. package/dist/styling/themes.d.ts +7 -0
  124. package/dist/styling/themes.d.ts.map +1 -0
  125. package/dist/styling-module.d.ts +178 -0
  126. package/dist/styling-module.d.ts.map +1 -0
  127. package/dist/styling.cjs +2 -0
  128. package/dist/styling.cjs.map +1 -0
  129. package/dist/styling.js +146 -0
  130. package/dist/styling.js.map +1 -0
  131. package/dist/terminal/color-converter.d.ts +73 -0
  132. package/dist/terminal/color-converter.d.ts.map +1 -0
  133. package/dist/terminal/formatter.d.ts +20 -0
  134. package/dist/terminal/formatter.d.ts.map +1 -0
  135. package/dist/terminal/terminal-renderer.d.ts +77 -0
  136. package/dist/terminal/terminal-renderer.d.ts.map +1 -0
  137. package/dist/transports/ConsoleTransport.d.ts +9 -0
  138. package/dist/transports/ConsoleTransport.d.ts.map +1 -0
  139. package/dist/transports/FileTransport.d.ts +15 -0
  140. package/dist/transports/FileTransport.d.ts.map +1 -0
  141. package/dist/transports/HttpTransport.d.ts +16 -0
  142. package/dist/transports/HttpTransport.d.ts.map +1 -0
  143. package/dist/transports/TransportManager.d.ts +14 -0
  144. package/dist/transports/TransportManager.d.ts.map +1 -0
  145. package/{src/transports/index.ts → dist/transports/index.d.ts} +1 -0
  146. package/dist/transports/index.d.ts.map +1 -0
  147. package/{src/types/core.ts → dist/types/core.d.ts} +25 -62
  148. package/dist/types/core.d.ts.map +1 -0
  149. package/{src/types/handlers.ts → dist/types/handlers.d.ts} +5 -15
  150. package/dist/types/handlers.d.ts.map +1 -0
  151. package/{src/types/hooks.ts → dist/types/hooks.d.ts} +3 -12
  152. package/dist/types/hooks.d.ts.map +1 -0
  153. package/dist/types/index.d.ts +11 -0
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/{src/types/serializers.ts → dist/types/serializers.d.ts} +1 -6
  156. package/dist/types/serializers.d.ts.map +1 -0
  157. package/{src/types/transports.ts → dist/types/transports.d.ts} +2 -7
  158. package/dist/types/transports.d.ts.map +1 -0
  159. package/dist/utils/adapter.d.ts +48 -0
  160. package/dist/utils/adapter.d.ts.map +1 -0
  161. package/dist/utils/ansi-colors.d.ts +156 -0
  162. package/dist/utils/ansi-colors.d.ts.map +1 -0
  163. package/dist/utils/environment-detector.d.ts +45 -0
  164. package/dist/utils/environment-detector.d.ts.map +1 -0
  165. package/dist/utils/environment.d.ts +47 -0
  166. package/dist/utils/environment.d.ts.map +1 -0
  167. package/dist/utils/formatting.d.ts +58 -0
  168. package/dist/utils/formatting.d.ts.map +1 -0
  169. package/dist/utils/index.d.ts +8 -0
  170. package/dist/utils/index.d.ts.map +1 -0
  171. package/dist/utils/opentui-detection.d.ts +34 -0
  172. package/dist/utils/opentui-detection.d.ts.map +1 -0
  173. package/dist/utils/output.d.ts +46 -0
  174. package/dist/utils/output.d.ts.map +1 -0
  175. package/dist/utils/stackTrace.d.ts +6 -0
  176. package/dist/utils/stackTrace.d.ts.map +1 -0
  177. package/dist/utils/timestamps.d.ts +20 -0
  178. package/dist/utils/timestamps.d.ts.map +1 -0
  179. package/{src/writers/BufferWriter.ts → dist/writers/BufferWriter.d.ts} +16 -77
  180. package/dist/writers/BufferWriter.d.ts.map +1 -0
  181. package/{src/writers/index.ts → dist/writers/index.d.ts} +1 -1
  182. package/dist/writers/index.d.ts.map +1 -0
  183. package/package.json +5 -1
  184. package/.claude/settings.local.json +0 -48
  185. package/.github/workflows/ci-quality.yml +0 -357
  186. package/.github/workflows/docs-demo.yml +0 -119
  187. package/.github/workflows/releases-core.yml +0 -512
  188. package/.github/workflows/releases-full.yml +0 -582
  189. package/.github/workflows-backup/ci.yml +0 -221
  190. package/.github/workflows-backup/nightly.yml +0 -196
  191. package/.github/workflows-backup/release-optimized.yml +0 -373
  192. package/.github/workflows-backup/release.yml +0 -269
  193. package/.release-notes-0.2.0.md +0 -129
  194. package/.yamllint +0 -28
  195. package/CHANGELOG.json +0 -1120
  196. package/CHANGELOG.md +0 -209
  197. package/CLAUDE.md +0 -217
  198. package/demo.html +0 -847
  199. package/docs/API.md +0 -918
  200. package/docs/CORE.md +0 -264
  201. package/docs/DEVELOPMENT.md +0 -731
  202. package/docs/EXPORTS.md +0 -467
  203. package/docs/PACKAGES.md +0 -244
  204. package/docs/STYLING.md +0 -405
  205. package/docs/_config.yml +0 -36
  206. package/docs/index.md +0 -179
  207. package/examples/README.md +0 -208
  208. package/examples/basic-logging.js +0 -75
  209. package/examples/data-export.js +0 -234
  210. package/examples/package.json +0 -16
  211. package/examples/performance-timing.js +0 -170
  212. package/examples/simplified-api.js +0 -124
  213. package/examples/styling-themes.js +0 -207
  214. package/index.html +0 -358
  215. package/packages/core/package.json +0 -57
  216. package/packages/exports/package.json +0 -41
  217. package/packages/nodejs-opentui/README.md +0 -232
  218. package/packages/nodejs-opentui/package.json +0 -72
  219. package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
  220. package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
  221. package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
  222. package/packages/nodejs-opentui/src/index.ts +0 -133
  223. package/packages/nodejs-opentui/src/types.ts +0 -158
  224. package/packages/nodejs-opentui/tsconfig.json +0 -20
  225. package/packages/styling/package.json +0 -41
  226. package/playground/demo-all.ts +0 -95
  227. package/playground/demo-box.ts +0 -85
  228. package/playground/demo-levels.ts +0 -56
  229. package/playground/demo-real-world.ts +0 -98
  230. package/playground/demo-spinner.ts +0 -77
  231. package/playground/demo-steps.ts +0 -72
  232. package/playground/demo-table.ts +0 -83
  233. package/project-utils/README.md +0 -172
  234. package/project-utils/auto-release-gemini.ts +0 -1193
  235. package/project-utils/auto-release-ui.ts +0 -1329
  236. package/project-utils/commit-generator.ts +0 -1385
  237. package/project-utils/commit-ui.ts +0 -264
  238. package/project-utils/git-utils.ts +0 -199
  239. package/project-utils/github-release-manager.ts +0 -466
  240. package/project-utils/project-config.ts +0 -260
  241. package/project-utils/prompt-templates.js +0 -345
  242. package/project-utils/prompt-templates.ts +0 -422
  243. package/project-utils/version-manager.ts +0 -1078
  244. package/src/Logger.ts +0 -1858
  245. package/src/ScopedLogger.ts +0 -256
  246. package/src/cli/CommandProcessor.ts +0 -248
  247. package/src/cli/commands/ConfigCommand.ts +0 -93
  248. package/src/cli/commands/ExportCommand.ts +0 -276
  249. package/src/cli/commands/HistoryCommand.ts +0 -117
  250. package/src/cli/commands/StatusCommand.ts +0 -112
  251. package/src/cli/commands/ThemeCommand.ts +0 -88
  252. package/src/cli/help.ts +0 -127
  253. package/src/cli/index.ts +0 -71
  254. package/src/cli-primitives/box.ts +0 -86
  255. package/src/cli-primitives/cli-table.ts +0 -62
  256. package/src/cli-primitives/divider.ts +0 -17
  257. package/src/cli-primitives/header.ts +0 -18
  258. package/src/cli-primitives/server-fallback.ts +0 -54
  259. package/src/cli-primitives/spinner.ts +0 -133
  260. package/src/cli-primitives/step.ts +0 -22
  261. package/src/constants.ts +0 -313
  262. package/src/core.ts +0 -397
  263. package/src/example.ts +0 -210
  264. package/src/exports-module.ts +0 -311
  265. package/src/handlers/AnalyticsLogHandler.ts +0 -22
  266. package/src/handlers/ExportLogHandler.ts +0 -610
  267. package/src/handlers/FileLogHandler.ts +0 -169
  268. package/src/handlers/RemoteLogHandler.ts +0 -42
  269. package/src/hooks/HookManager.ts +0 -177
  270. package/src/index.ts +0 -395
  271. package/src/main.ts +0 -196
  272. package/src/serializers/SerializerRegistry.ts +0 -173
  273. package/src/style.css +0 -96
  274. package/src/styling/LogStyleBuilder.ts +0 -355
  275. package/src/styling/SemanticStyles.ts +0 -380
  276. package/src/styling/SmartPresets.ts +0 -288
  277. package/src/styling/StyleBuilder.ts +0 -319
  278. package/src/styling/StyleCache.ts +0 -131
  279. package/src/styling/banners.ts +0 -168
  280. package/src/styling/index.ts +0 -27
  281. package/src/styling/themes.ts +0 -235
  282. package/src/styling-module.ts +0 -244
  283. package/src/terminal/color-converter.ts +0 -315
  284. package/src/terminal/formatter.ts +0 -242
  285. package/src/terminal/terminal-renderer.ts +0 -342
  286. package/src/transports/ConsoleTransport.ts +0 -28
  287. package/src/transports/FileTransport.ts +0 -53
  288. package/src/transports/HttpTransport.ts +0 -56
  289. package/src/transports/TransportManager.ts +0 -130
  290. package/src/types/index.ts +0 -83
  291. package/src/typescript.svg +0 -1
  292. package/src/utils/adapter.ts +0 -291
  293. package/src/utils/ansi-colors.ts +0 -333
  294. package/src/utils/environment-detector.ts +0 -170
  295. package/src/utils/environment.ts +0 -94
  296. package/src/utils/formatting.ts +0 -332
  297. package/src/utils/index.ts +0 -33
  298. package/src/utils/opentui-detection.ts +0 -138
  299. package/src/utils/output.ts +0 -227
  300. package/src/utils/stackTrace.ts +0 -144
  301. package/src/utils/timestamps.ts +0 -80
  302. package/src/vite-env.d.ts +0 -1
  303. package/test-core-browser.html +0 -237
  304. package/test-core-node.js +0 -63
  305. package/tests/test-conflict-resolution.ts +0 -391
  306. package/tests/validate-workflows.sh +0 -131
  307. package/tests/yaml-autofix.sh +0 -146
  308. package/tsconfig.json +0 -50
  309. package/vite.config.ts +0 -256
  310. /package/{public → dist}/vite.svg +0 -0
@@ -1,342 +0,0 @@
1
- /**
2
- * Terminal Renderer - ANSI color rendering for terminal environments
3
- * Converts CSS-based styling to ANSI escape sequences for terminal output
4
- */
5
-
6
- import type { LogLevel } from '../types/index.js';
7
- import type { LogStyles } from '../types/index.js';
8
- import { getANSIForeground, getANSIBackground, ANSI, type ColorCapability } from './color-converter.js';
9
-
10
- export type ANSIStyle = {
11
- text: string;
12
- timestamp?: string;
13
- level?: string;
14
- prefix?: string;
15
- message?: string;
16
- location?: string;
17
- reset: string;
18
- };
19
-
20
- export class TerminalRenderer {
21
- private colorCapability: ColorCapability;
22
-
23
- constructor(colorCapability: ColorCapability = 'full') {
24
- this.colorCapability = colorCapability;
25
- }
26
-
27
- /**
28
- * Get ANSI color codes - now supports truecolor/256-color
29
- */
30
- private getColorCode(color: string, background: boolean = false): string {
31
- return background
32
- ? getANSIBackground(color, this.colorCapability)
33
- : getANSIForeground(color, this.colorCapability);
34
- }
35
-
36
- /**
37
- * Get ANSI style codes
38
- */
39
- private getStyleCode(styles: string[]): string {
40
- const styleCodes: Record<string, string> = {
41
- 'bold': '1',
42
- 'dim': '2',
43
- 'italic': '3',
44
- 'underline': '4',
45
- 'reset': '0'
46
- };
47
-
48
- const codes = styles.map(style => styleCodes[style] || '0').join(';');
49
- return codes ? `\x1b[${codes}m` : '';
50
- }
51
-
52
- /**
53
- * Convert log styles to ANSI formatting
54
- */
55
- renderTerminal(
56
- level: LogLevel,
57
- message: string,
58
- timestamp?: string,
59
- prefix?: string,
60
- location?: string,
61
- styles?: LogStyles
62
- ): ANSIStyle {
63
- const reset = '\x1b[0m';
64
- const result: ANSIStyle = { text: '', reset };
65
-
66
- // Apply preset styles if provided
67
- if (styles) {
68
- result.timestamp = this.styleTimestamp(timestamp, styles.timestamp);
69
- result.level = this.styleLevel(level, styles.level);
70
- result.prefix = this.stylePrefix(prefix, styles.prefix);
71
- result.message = this.styleMessage(message, styles.message);
72
- result.location = this.styleLocation(location, styles.location);
73
- } else {
74
- // Default styling based on level
75
- result.timestamp = this.styleTimestamp(timestamp);
76
- result.level = this.styleLevel(level);
77
- result.prefix = this.stylePrefix(prefix);
78
- result.message = this.styleMessage(message);
79
- result.location = this.styleLocation(location);
80
- }
81
-
82
- // Build complete text
83
- const parts: string[] = [];
84
- if (result.timestamp) parts.push(result.timestamp);
85
- if (result.level) parts.push(result.level);
86
- if (result.prefix) parts.push(result.prefix);
87
- if (result.message) parts.push(result.message);
88
- if (result.location) parts.push(result.location);
89
-
90
- result.text = parts.join(' ') + reset;
91
- return result;
92
- }
93
-
94
- /**
95
- * Style timestamp based on preset or defaults
96
- */
97
- private styleTimestamp(timestamp?: string, style?: LogStyles['timestamp']): string {
98
- if (!timestamp || !style?.show) return '';
99
-
100
- if (this.colorCapability === 'none') {
101
- return timestamp;
102
- }
103
-
104
- const dimStyle = this.getStyleCode(['dim']);
105
- return `${dimStyle}${timestamp}${'\x1b[0m'}`;
106
- }
107
-
108
- /**
109
- * Style level with appropriate colors and formatting
110
- */
111
- private styleLevel(level: LogLevel, style?: LogStyles['level']): string {
112
- if (!style?.show) return '';
113
-
114
- const levelText = this.getLevelText(level);
115
- const levelColors: Record<LogLevel, string> = {
116
- 'debug': 'magenta',
117
- 'info': 'blue',
118
- 'warn': 'yellow',
119
- 'error': 'red',
120
- 'critical': 'red'
121
- };
122
-
123
- if (this.colorCapability === 'none') {
124
- return `[${levelText}]`;
125
- }
126
-
127
- const color = levelColors[level] || 'white';
128
- const colorCode = this.getColorCode(color);
129
- const boldStyle = this.getStyleCode(['bold']);
130
-
131
- if (style?.style === 'compact') {
132
- return `${colorCode}[${levelText}]${'\x1b[0m'}`;
133
- } else {
134
- return `${colorCode}${boldStyle}[${levelText}]${'\x1b[0m'}`;
135
- }
136
- }
137
-
138
- /**
139
- * Style prefix based on preset - now as a badge
140
- */
141
- private stylePrefix(prefix?: string, style?: LogStyles['prefix']): string {
142
- if (!prefix || !style?.show) return '';
143
-
144
- if (this.colorCapability === 'none') {
145
- return `[${prefix}]`;
146
- }
147
-
148
- // Create badge styling similar to level badges
149
- const colorCode = this.getColorCode('cyan');
150
- const bgBlack = '\x1b[40m';
151
- return `${bgBlack}${colorCode}[${prefix.toUpperCase()}]${'\x1b[0m'}`;
152
- }
153
-
154
- /**
155
- * Style message based on preset
156
- */
157
- private styleMessage(message: string, style?: LogStyles['message']): string {
158
- if (!style?.show) return message;
159
-
160
- return message; // Messages usually don't need styling
161
- }
162
-
163
- /**
164
- * Style location (file:line) information
165
- */
166
- private styleLocation(location?: string, style?: LogStyles['location']): string {
167
- if (!location || !style?.show) return '';
168
-
169
- if (this.colorCapability === 'none') {
170
- return `(${location})`;
171
- }
172
-
173
- const dimStyle = this.getStyleCode(['dim']);
174
- if (style?.style === 'clickable') {
175
- const underlineStyle = this.getStyleCode(['dim', 'underline']);
176
- return `${underlineStyle}(${location})${'\x1b[0m'}`;
177
- }
178
-
179
- return `${dimStyle}(${location})${'\x1b[0m'}`;
180
- }
181
-
182
- /**
183
- * Get text representation of log level
184
- */
185
- public getLevelText(level: LogLevel): string {
186
- const levelMap: Record<LogLevel, string> = {
187
- 'debug': 'DEBUG',
188
- 'info': 'INFO',
189
- 'warn': 'WARN',
190
- 'error': 'ERROR',
191
- 'critical': 'CRITICAL'
192
- };
193
-
194
- return levelMap[level] || String(level).toUpperCase();
195
- }
196
-
197
- /**
198
- * Create cyberpunk-style ANSI rendering with truecolor support
199
- */
200
- renderCyberpunk(
201
- level: LogLevel,
202
- message: string,
203
- timestamp?: string,
204
- prefix?: string,
205
- location?: string
206
- ): ANSIStyle {
207
- const reset = ANSI.reset;
208
-
209
- const cyberpunkColors: Record<LogLevel, string> = {
210
- 'debug': '#ff00ff', // Neon magenta
211
- 'info': '#00ffff', // Neon cyan
212
- 'warn': '#ffff00', // Neon yellow
213
- 'error': '#ff0040', // Neon red-pink
214
- 'critical': '#ff0000' // Pure red
215
- };
216
-
217
- const parts: string[] = [];
218
-
219
- if (timestamp) {
220
- parts.push(`${ANSI.dim}${timestamp}${reset}`);
221
- }
222
-
223
- const levelColor = this.getColorCode(cyberpunkColors[level] || '#ffffff');
224
- const bgBlack = ANSI.bg.black;
225
- const bold = level === 'critical' ? ANSI.bold : '';
226
- parts.push(`${bgBlack}${levelColor}${bold} ${this.getLevelText(level)} ${reset}`);
227
-
228
- if (prefix) {
229
- const cyanColor = this.getColorCode('#00ffff');
230
- parts.push(`${bgBlack}${cyanColor}[${prefix.toUpperCase()}]${reset}`);
231
- }
232
-
233
- parts.push(message);
234
-
235
- if (location) {
236
- parts.push(`${ANSI.dim}(${location})${reset}`);
237
- }
238
-
239
- return {
240
- text: parts.join(' '),
241
- reset
242
- };
243
- }
244
-
245
- /**
246
- * Create minimal ANSI rendering with truecolor support
247
- */
248
- renderMinimal(
249
- level: LogLevel,
250
- message: string,
251
- timestamp?: string,
252
- prefix?: string
253
- ): ANSIStyle {
254
- const reset = ANSI.reset;
255
-
256
- const minimalColors: Record<LogLevel, string> = {
257
- 'debug': '#c678dd', // Soft purple
258
- 'info': '#61afef', // Soft blue
259
- 'warn': '#e5c07b', // Soft yellow
260
- 'error': '#e06c75', // Soft red
261
- 'critical': '#be5046' // Dark red
262
- };
263
-
264
- const parts: string[] = [];
265
-
266
- if (timestamp) {
267
- parts.push(`${ANSI.dim}${timestamp}${reset}`);
268
- }
269
-
270
- const levelColor = this.getColorCode(minimalColors[level] || '#abb2bf');
271
- const bold = level === 'critical' ? ANSI.bold : '';
272
- parts.push(`${levelColor}${bold}${this.getLevelText(level)}:${reset}`);
273
-
274
- if (prefix) {
275
- const cyanColor = this.getColorCode('#56b6c2');
276
- parts.push(`${cyanColor}[${prefix.toUpperCase()}]${reset}`);
277
- }
278
-
279
- parts.push(message);
280
-
281
- return {
282
- text: parts.join(' '),
283
- reset
284
- };
285
- }
286
-
287
- /**
288
- * Get chalk-like interface for log level with truecolor support
289
- */
290
- public getChalkForLevel(level: LogLevel): ChalkLikeInterface {
291
- const levelColors: Record<LogLevel, string> = {
292
- 'debug': '#c678dd',
293
- 'info': '#61afef',
294
- 'warn': '#e5c07b',
295
- 'error': '#e06c75',
296
- 'critical': '#be5046'
297
- };
298
-
299
- const reset = ANSI.reset;
300
-
301
- return {
302
- color: (text: string) => {
303
- const color = levelColors[level] || '#abb2bf';
304
- const colorCode = this.getColorCode(color);
305
- return `${colorCode}${text}${reset}`;
306
- },
307
- bold: (text: string) => `${ANSI.bold}${text}${reset}`,
308
- dim: (text: string) => `${ANSI.dim}${text}${reset}`,
309
- bgGray: (text: string) => `${ANSI.bg.gray}${text}${reset}`,
310
- bgBlue: (text: string) => `${this.getColorCode('#1e3a5f', true)}${text}${reset}`,
311
- reset: (text: string) => text,
312
- cyan: {
313
- bold: (text: string) => {
314
- const cyan = this.getColorCode('#00ffff');
315
- return `${cyan}${ANSI.bold}${text}${reset}`;
316
- },
317
- dim: (text: string) => {
318
- const cyan = this.getColorCode('#00ffff');
319
- return `${cyan}${ANSI.dim}${text}${reset}`;
320
- },
321
- bg: (text: string) => {
322
- const cyan = this.getColorCode('#00ffff');
323
- return `${ANSI.bg.black}${cyan}[${text.toUpperCase()}]${reset}`;
324
- }
325
- }
326
- };
327
- }
328
- }
329
-
330
- export interface ChalkLikeInterface {
331
- color: (text: string) => string;
332
- bold: (text: string) => string;
333
- dim: (text: string) => string;
334
- bgGray: (text: string) => string;
335
- bgBlue: (text: string) => string;
336
- reset: (text: string) => string;
337
- cyan: {
338
- bold: (text: string) => string;
339
- dim: (text: string) => string;
340
- bg: (text: string) => string;
341
- };
342
- }
@@ -1,28 +0,0 @@
1
- import type { TransportRecord, TransportOptions, ITransport, LogLevel } from '../types/index.js';
2
-
3
- export class ConsoleTransport implements ITransport {
4
- readonly name = 'console';
5
-
6
- constructor(private options?: TransportOptions) {}
7
-
8
- write(record: TransportRecord): void {
9
- const method = this.getConsoleMethod(record.level);
10
- const prefix = record.prefix ? `[${record.prefix}] ` : '';
11
- const location = record.location
12
- ? ` (${record.location.file}:${record.location.line})`
13
- : '';
14
-
15
- console[method](`[${record.level.toUpperCase()}]${prefix} ${record.msg}${location}`);
16
- }
17
-
18
- private getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error' {
19
- switch (level) {
20
- case 'debug': return 'log';
21
- case 'info': return 'info';
22
- case 'warn': return 'warn';
23
- case 'error':
24
- case 'critical': return 'error';
25
- default: return 'log';
26
- }
27
- }
28
- }
@@ -1,53 +0,0 @@
1
- import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';
2
-
3
- export interface FileTransportOptions extends TransportOptions {
4
- destination?: string;
5
- }
6
-
7
- export class FileTransport implements ITransport {
8
- readonly name = 'file';
9
- private buffer: string[] = [];
10
- private flushTimer?: ReturnType<typeof setInterval>;
11
- private options: FileTransportOptions;
12
-
13
- constructor(options?: FileTransportOptions) {
14
- this.options = options || {};
15
-
16
- if (this.options.flushInterval) {
17
- this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);
18
- }
19
- }
20
-
21
- write(record: TransportRecord): void {
22
- const line = JSON.stringify(record) + '\n';
23
- this.buffer.push(line);
24
-
25
- if (this.buffer.length >= (this.options.batchSize || 100)) {
26
- this.flush();
27
- }
28
- }
29
-
30
- async flush(): Promise<void> {
31
- if (this.buffer.length === 0) return;
32
-
33
- const lines = this.buffer.join('');
34
- this.buffer = [];
35
-
36
- if (typeof globalThis.process !== 'undefined' && typeof require === 'function') {
37
- try {
38
- const fs = require('fs');
39
- const dest = this.options.destination || 'app.log';
40
- fs.appendFileSync(dest, lines);
41
- } catch {
42
- // Silent fail in browser or if fs not available
43
- }
44
- }
45
- }
46
-
47
- close(): void {
48
- if (this.flushTimer) {
49
- clearInterval(this.flushTimer);
50
- }
51
- this.flush();
52
- }
53
- }
@@ -1,56 +0,0 @@
1
- import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';
2
-
3
- export interface HttpTransportOptions extends TransportOptions {
4
- url?: string;
5
- headers?: Record<string, string>;
6
- }
7
-
8
- export class HttpTransport implements ITransport {
9
- readonly name = 'http';
10
- private buffer: TransportRecord[] = [];
11
- private flushTimer?: ReturnType<typeof setInterval>;
12
- private options: HttpTransportOptions;
13
-
14
- constructor(options?: HttpTransportOptions) {
15
- this.options = options || {};
16
-
17
- if (this.options.flushInterval) {
18
- this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);
19
- }
20
- }
21
-
22
- write(record: TransportRecord): void {
23
- this.buffer.push(record);
24
-
25
- if (this.buffer.length >= (this.options.batchSize || 50)) {
26
- this.flush();
27
- }
28
- }
29
-
30
- async flush(): Promise<void> {
31
- if (this.buffer.length === 0 || !this.options.url) return;
32
-
33
- const records = [...this.buffer];
34
- this.buffer = [];
35
-
36
- try {
37
- await fetch(this.options.url, {
38
- method: 'POST',
39
- headers: {
40
- 'Content-Type': 'application/json',
41
- ...this.options.headers
42
- },
43
- body: JSON.stringify({ logs: records })
44
- });
45
- } catch {
46
- this.buffer.unshift(...records);
47
- }
48
- }
49
-
50
- close(): void {
51
- if (this.flushTimer) {
52
- clearInterval(this.flushTimer);
53
- }
54
- this.flush();
55
- }
56
- }
@@ -1,130 +0,0 @@
1
- import type {
2
- TransportRecord,
3
- TransportTarget,
4
- TransportOptions,
5
- ITransport,
6
- ITransportManager,
7
- LogLevel
8
- } from '../types/index.js';
9
- import { LOG_LEVELS } from '../types/index.js';
10
-
11
- function generateTransportId(): string {
12
- return `transport-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`;
13
- }
14
-
15
- interface TransportEntry {
16
- id: string;
17
- transport: ITransport;
18
- options: TransportOptions;
19
- level: LogLevel;
20
- levelValue: number;
21
- }
22
-
23
- export class TransportManager implements ITransportManager {
24
- private transports: Map<string, TransportEntry> = new Map();
25
- private defaultLevel: LogLevel = 'info';
26
-
27
- constructor(defaultLevel?: LogLevel) {
28
- if (defaultLevel) {
29
- this.defaultLevel = defaultLevel;
30
- }
31
- }
32
-
33
- add(target: TransportTarget): string {
34
- const id = generateTransportId();
35
- const level = target.level || this.defaultLevel;
36
-
37
- let transport: ITransport;
38
-
39
- if (typeof target.target === 'string') {
40
- throw new Error(`String transport targets not supported. Use inline transport object.`);
41
- } else {
42
- transport = target.target;
43
- }
44
-
45
- const entry: TransportEntry = {
46
- id,
47
- transport,
48
- options: target.options || {},
49
- level,
50
- levelValue: LOG_LEVELS[level]
51
- };
52
-
53
- this.transports.set(id, entry);
54
- return id;
55
- }
56
-
57
- remove(id: string): boolean {
58
- const entry = this.transports.get(id);
59
- if (entry) {
60
- entry.transport.close?.();
61
- return this.transports.delete(id);
62
- }
63
- return false;
64
- }
65
-
66
- async write(record: TransportRecord): Promise<void> {
67
- const promises: Promise<void>[] = [];
68
-
69
- for (const entry of this.transports.values()) {
70
- if (record.levelValue < entry.levelValue) {
71
- continue;
72
- }
73
-
74
- let transformedRecord = record;
75
- if (entry.options.transform) {
76
- const result = entry.options.transform(record);
77
- if (result === null) continue;
78
- transformedRecord = result;
79
- }
80
-
81
- const result = entry.transport.write(transformedRecord);
82
- if (result instanceof Promise) {
83
- promises.push(result);
84
- }
85
- }
86
-
87
- await Promise.all(promises);
88
- }
89
-
90
- async flush(): Promise<void> {
91
- const promises: Promise<void>[] = [];
92
-
93
- for (const entry of this.transports.values()) {
94
- if (entry.transport.flush) {
95
- const result = entry.transport.flush();
96
- if (result instanceof Promise) {
97
- promises.push(result);
98
- }
99
- }
100
- }
101
-
102
- await Promise.all(promises);
103
- }
104
-
105
- async close(): Promise<void> {
106
- await this.flush();
107
-
108
- const promises: Promise<void>[] = [];
109
-
110
- for (const entry of this.transports.values()) {
111
- if (entry.transport.close) {
112
- const result = entry.transport.close();
113
- if (result instanceof Promise) {
114
- promises.push(result);
115
- }
116
- }
117
- }
118
-
119
- await Promise.all(promises);
120
- this.transports.clear();
121
- }
122
-
123
- get count(): number {
124
- return this.transports.size;
125
- }
126
-
127
- list(): string[] {
128
- return Array.from(this.transports.keys());
129
- }
130
- }
@@ -1,83 +0,0 @@
1
- /**
2
- * @fileoverview Type definitions exports for Advanced Logger
3
- */
4
-
5
- // Core types
6
- export type {
7
- LogLevel,
8
- Verbosity,
9
- ThemeVariant,
10
- DevToolsTheme,
11
- BannerType,
12
- ExportFormat,
13
- OutputFormat,
14
- LoggerConfig,
15
- StackInfo,
16
- TimerEntry,
17
- TimerResult,
18
- StyleOptions,
19
- AdaptiveColors,
20
- SpacingType,
21
- LogLayout,
22
- LogPartConfig,
23
- LogStyles,
24
- IScopedLogger,
25
- IAPILogger,
26
- IComponentLogger,
27
- Bindings,
28
- BadgeStyle,
29
- TimestampFormat,
30
- ColumnAlign,
31
- ColumnConfig,
32
- LogOptions,
33
- CLILogLevel,
34
- ISpinnerHandle,
35
- IBoxOptions,
36
- ITableOptions,
37
- } from './core.js';
38
-
39
- export { LOG_LEVELS } from './core.js';
40
-
41
- // Handler types
42
- export type {
43
- LogMetadata,
44
- ILogHandler,
45
- LogEntry,
46
- ExportFilters,
47
- ExportOptions,
48
- ExportResult,
49
- BufferStats,
50
- } from './handlers.js';
51
-
52
- // Serializer types
53
- export type {
54
- SerializerFn,
55
- SerializerContext,
56
- SerializerEntry,
57
- SerializerConfig,
58
- ISerializerRegistry,
59
- } from './serializers.js';
60
-
61
- // Hook types
62
- export type {
63
- HookLogEntry,
64
- HookEvent,
65
- HookCallback,
66
- MiddlewareFn,
67
- HookRegistration,
68
- MiddlewareRegistration,
69
- IHookManager,
70
- } from './hooks.js';
71
-
72
- // Transport types
73
- export type {
74
- TransportRecord,
75
- TransportOptions,
76
- TransportTarget,
77
- ITransport,
78
- IBufferedTransport,
79
- ITransportManager,
80
- } from './transports.js';
81
-
82
- // Style Cache types
83
- export type { StyleCacheConfig } from '../styling/StyleCache.js';
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#007ACC" d="M0 128v128h256V0H0z"></path><path fill="#FFF" d="m56.612 128.85l-.081 10.483h33.32v94.68h23.568v-94.68h33.321v-10.28c0-5.69-.122-10.444-.284-10.566c-.122-.162-20.4-.244-44.983-.203l-44.74.122l-.121 10.443Zm149.955-10.742c6.501 1.625 11.459 4.51 16.01 9.224c2.357 2.52 5.851 7.111 6.136 8.208c.08.325-11.053 7.802-17.798 11.988c-.244.162-1.22-.894-2.317-2.52c-3.291-4.795-6.745-6.867-12.028-7.233c-7.76-.528-12.759 3.535-12.718 10.321c0 1.992.284 3.17 1.097 4.795c1.707 3.536 4.876 5.649 14.832 9.956c18.326 7.883 26.168 13.084 31.045 20.48c5.445 8.249 6.664 21.415 2.966 31.208c-4.063 10.646-14.14 17.879-28.323 20.276c-4.388.772-14.79.65-19.504-.203c-10.28-1.828-20.033-6.908-26.047-13.572c-2.357-2.6-6.949-9.387-6.664-9.874c.122-.163 1.178-.813 2.356-1.504c1.138-.65 5.446-3.129 9.509-5.485l7.355-4.267l1.544 2.276c2.154 3.29 6.867 7.801 9.712 9.305c8.167 4.307 19.383 3.698 24.909-1.26c2.357-2.153 3.332-4.388 3.332-7.68c0-2.966-.366-4.266-1.91-6.501c-1.99-2.845-6.054-5.242-17.595-10.24c-13.206-5.69-18.895-9.224-24.096-14.832c-3.007-3.25-5.852-8.452-7.03-12.8c-.975-3.617-1.22-12.678-.447-16.335c2.723-12.76 12.353-21.659 26.25-24.3c4.51-.853 14.994-.528 19.424.569Z"></path></svg>