@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,256 +0,0 @@
1
- import { Logger } from './Logger.js';
2
- import type { TimerEntry, Bindings, ISpinnerHandle, IBoxOptions, ITableOptions, CLILogLevel } from './types/index.js';
3
-
4
- export class ScopedLogger {
5
- private readonly parent: Logger;
6
- private readonly scopeName: string;
7
- private badgeList: string[] = [];
8
- private contextStack: string[] = [];
9
- private _timers?: Map<string, TimerEntry>;
10
-
11
- constructor(parent: Logger, scopeName: string) {
12
- this.parent = parent;
13
- this.scopeName = scopeName;
14
- }
15
-
16
- private get timers(): Map<string, TimerEntry> {
17
- if (!this._timers) this._timers = new Map();
18
- return this._timers;
19
- }
20
-
21
- private getBindings(): Bindings {
22
- return {
23
- scope: this.getScopePrefix(),
24
- badges: this.badgeList.length > 0 ? [...this.badgeList] : undefined,
25
- };
26
- }
27
-
28
- private getScopePrefix(): string {
29
- if (this.contextStack.length === 0) return this.scopeName;
30
- return [this.scopeName, ...this.contextStack].join(':');
31
- }
32
-
33
- badges(badges: string[]): this {
34
- this.badgeList = [...badges];
35
- return this;
36
- }
37
-
38
- badge(badge: string): this {
39
- if (!this.badgeList.includes(badge)) {
40
- this.badgeList.push(badge);
41
- }
42
- return this;
43
- }
44
-
45
- clearBadges(): this {
46
- this.badgeList = [];
47
- return this;
48
- }
49
-
50
- style(presetName: string): this {
51
- this.parent.setTheme(presetName as any);
52
- return this;
53
- }
54
-
55
- context(contextName: string): ContextLogger {
56
- return new ContextLogger(this, contextName);
57
- }
58
-
59
- time(label: string): void {
60
- this.timers.set(label, {
61
- label: `${this.scopeName}:${label}`,
62
- startTime: performance.now(),
63
- });
64
- }
65
-
66
- timeEnd(label: string): number | undefined {
67
- const timer = this.timers.get(label);
68
- if (!timer) {
69
- this.warn(`Timer '${label}' not found`);
70
- return undefined;
71
- }
72
- const elapsed = performance.now() - timer.startTime;
73
- this.timers.delete(label);
74
- this.success(`Timer: ${label} - ${elapsed.toFixed(2)}ms`);
75
- return elapsed;
76
- }
77
-
78
- debug(...args: any[]): void {
79
- this.parent.logWithBindings(this.getBindings(), 'debug', ...args);
80
- }
81
-
82
- info(...args: any[]): void {
83
- this.parent.logWithBindings(this.getBindings(), 'info', ...args);
84
- }
85
-
86
- warn(...args: any[]): void {
87
- this.parent.logWithBindings(this.getBindings(), 'warn', ...args);
88
- }
89
-
90
- error(...args: any[]): void {
91
- this.parent.logWithBindings(this.getBindings(), 'error', ...args);
92
- }
93
-
94
- success(...args: any[]): void {
95
- const bindings = this.getBindings();
96
- this.parent.logWithBindings(bindings, 'info', ...args);
97
- }
98
-
99
- critical(...args: any[]): void {
100
- this.parent.logWithBindings(this.getBindings(), 'critical', ...args);
101
- }
102
-
103
- trace(...args: any[]): void {
104
- this.parent.logWithBindings(this.getBindings(), 'debug', ...args);
105
- console.trace(`[${this.scopeName}]`);
106
- }
107
-
108
- // ===== CLI PRIMITIVES (v5.0 delegation) =====
109
-
110
- /** @see Logger.step */
111
- step(current: number, total: number, message: string): void {
112
- this.parent.step(current, total, message);
113
- }
114
-
115
- /** @see Logger.header */
116
- header(title: string, subtitle?: string): void {
117
- this.parent.header(title, subtitle);
118
- }
119
-
120
- /** @see Logger.divider */
121
- divider(): void {
122
- this.parent.divider();
123
- }
124
-
125
- /** @see Logger.blank */
126
- blank(): void {
127
- this.parent.blank();
128
- }
129
-
130
- /** @see Logger.box */
131
- box(content: string, options?: IBoxOptions): void {
132
- this.parent.box(content, options);
133
- }
134
-
135
- /** @see Logger.cliTable */
136
- cliTable(rows: Record<string, unknown>[], options?: ITableOptions): void {
137
- this.parent.cliTable(rows, options);
138
- }
139
-
140
- /** @see Logger.spinner */
141
- spinner(message: string): ISpinnerHandle {
142
- return this.parent.spinner(message);
143
- }
144
-
145
- /** @see Logger.setCLILevel */
146
- setCLILevel(level: CLILogLevel): void {
147
- this.parent.setCLILevel(level);
148
- }
149
-
150
- _pushContext(context: string): void {
151
- this.contextStack.push(context);
152
- }
153
-
154
- _popContext(): void {
155
- this.contextStack.pop();
156
- }
157
- }
158
-
159
- export class APILogger extends ScopedLogger {
160
- constructor(parent: Logger, apiName: string) {
161
- super(parent, `API:${apiName}`);
162
- this.badge('API');
163
- }
164
-
165
- slow(message: string, duration?: number): void {
166
- this.badge('SLOW');
167
- const msg = duration ? `${message} (${duration}ms)` : message;
168
- this.warn(msg);
169
- }
170
-
171
- rateLimit(message: string): void {
172
- this.badge('RATE_LIMIT');
173
- this.warn(message);
174
- }
175
-
176
- auth(message: string): void {
177
- this.badge('AUTH');
178
- this.error(message);
179
- }
180
-
181
- deprecated(message: string): void {
182
- this.badge('DEPRECATED');
183
- this.warn(message);
184
- }
185
- }
186
-
187
- export class ComponentLogger extends ScopedLogger {
188
- constructor(parent: Logger, componentName: string) {
189
- super(parent, componentName);
190
- this.badge('COMPONENT');
191
- }
192
-
193
- lifecycle(event: string, message?: string): void {
194
- this.badge('LIFECYCLE');
195
- const msg = message ? `${event}: ${message}` : event;
196
- this.info(msg);
197
- }
198
-
199
- stateChange(from: string, to: string, data?: any): void {
200
- this.badge('STATE');
201
- const msg = `${from} → ${to}`;
202
- if (data) {
203
- this.info(msg, data);
204
- } else {
205
- this.info(msg);
206
- }
207
- }
208
-
209
- propsChange(changes: Record<string, any>): void {
210
- this.badge('PROPS');
211
- this.debug('Props changed:', changes);
212
- }
213
- }
214
-
215
- export class ContextLogger {
216
- private parentLogger: ScopedLogger;
217
- private contextName: string;
218
-
219
- constructor(parentLogger: ScopedLogger, contextName: string) {
220
- this.parentLogger = parentLogger;
221
- this.contextName = contextName;
222
- }
223
-
224
- run<T>(fn: () => T): T {
225
- this.parentLogger._pushContext(this.contextName);
226
- try {
227
- return fn();
228
- } finally {
229
- this.parentLogger._popContext();
230
- }
231
- }
232
-
233
- async runAsync<T>(fn: () => Promise<T>): Promise<T> {
234
- this.parentLogger._pushContext(this.contextName);
235
- try {
236
- return await fn();
237
- } finally {
238
- this.parentLogger._popContext();
239
- }
240
- }
241
-
242
- start(): void {
243
- this.parentLogger._pushContext(this.contextName);
244
- }
245
-
246
- end(): void {
247
- this.parentLogger._popContext();
248
- }
249
-
250
- debug(...args: any[]): void { this.parentLogger.debug(...args); }
251
- info(...args: any[]): void { this.parentLogger.info(...args); }
252
- warn(...args: any[]): void { this.parentLogger.warn(...args); }
253
- error(...args: any[]): void { this.parentLogger.error(...args); }
254
- success(...args: any[]): void { this.parentLogger.success(...args); }
255
- critical(...args: any[]): void { this.parentLogger.critical(...args); }
256
- }
@@ -1,248 +0,0 @@
1
- /**
2
- * @fileoverview CLI Command processor for Advanced Logger
3
- */
4
-
5
- import type { Logger } from '../Logger.js';
6
-
7
- /**
8
- * Base interface for CLI commands
9
- */
10
- export interface ICommand {
11
- name: string;
12
- description: string;
13
- usage: string;
14
- category?: string;
15
- aliases?: string[];
16
- execute(args: string, logger: Logger): void | Promise<void>;
17
- }
18
-
19
- /**
20
- * Plugin interface for extending CLI functionality
21
- */
22
- export interface ICLIPlugin {
23
- name: string;
24
- version: string;
25
- description: string;
26
- commands: ICommand[];
27
- initialize?(processor: CommandProcessor, logger: Logger): void;
28
- cleanup?(): void;
29
- }
30
-
31
- /**
32
- * Command history entry
33
- */
34
- interface HistoryEntry {
35
- command: string;
36
- timestamp: Date;
37
- success: boolean;
38
- }
39
-
40
- /**
41
- * CLI command processor
42
- */
43
- export class CommandProcessor {
44
- private commands: Map<string, ICommand> = new Map();
45
- private aliases: Map<string, string> = new Map();
46
- private plugins: Map<string, ICLIPlugin> = new Map();
47
- private history: HistoryEntry[] = [];
48
- private maxHistorySize: number = 100;
49
- private isInteractiveMode: boolean = false;
50
-
51
- /**
52
- * Register a command
53
- */
54
- registerCommand(command: ICommand): void {
55
- this.commands.set(command.name, command);
56
-
57
- // Register aliases
58
- if (command.aliases) {
59
- for (const alias of command.aliases) {
60
- this.aliases.set(alias, command.name);
61
- }
62
- }
63
- }
64
-
65
- /**
66
- * Register a plugin
67
- */
68
- registerPlugin(plugin: ICLIPlugin, logger?: Logger): void {
69
- if (this.plugins.has(plugin.name)) {
70
- throw new Error(`Plugin ${plugin.name} is already registered`);
71
- }
72
-
73
- this.plugins.set(plugin.name, plugin);
74
-
75
- // Register plugin commands
76
- for (const command of plugin.commands) {
77
- this.registerCommand(command);
78
- }
79
-
80
- // Initialize plugin
81
- if (plugin.initialize && logger) {
82
- plugin.initialize(this, logger);
83
- }
84
- }
85
-
86
- /**
87
- * Unregister a plugin
88
- */
89
- unregisterPlugin(pluginName: string): void {
90
- const plugin = this.plugins.get(pluginName);
91
- if (!plugin) return;
92
-
93
- // Remove plugin commands
94
- for (const command of plugin.commands) {
95
- this.commands.delete(command.name);
96
- if (command.aliases) {
97
- for (const alias of command.aliases) {
98
- this.aliases.delete(alias);
99
- }
100
- }
101
- }
102
-
103
- // Cleanup plugin
104
- if (plugin.cleanup) {
105
- plugin.cleanup();
106
- }
107
-
108
- this.plugins.delete(pluginName);
109
- }
110
-
111
- /**
112
- * Get all registered commands
113
- */
114
- getCommands(): ICommand[] {
115
- return Array.from(this.commands.values());
116
- }
117
-
118
- /**
119
- * Get a specific command
120
- */
121
- getCommand(name: string): ICommand | undefined {
122
- // Check direct command name
123
- let command = this.commands.get(name);
124
- if (command) return command;
125
-
126
- // Check aliases
127
- const aliasTarget = this.aliases.get(name);
128
- if (aliasTarget) {
129
- return this.commands.get(aliasTarget);
130
- }
131
-
132
- return undefined;
133
- }
134
-
135
- /**
136
- * Get command history
137
- */
138
- getHistory(): HistoryEntry[] {
139
- return [...this.history];
140
- }
141
-
142
- /**
143
- * Clear command history
144
- */
145
- clearHistory(): void {
146
- this.history = [];
147
- }
148
-
149
- /**
150
- * Get registered plugins
151
- */
152
- getPlugins(): ICLIPlugin[] {
153
- return Array.from(this.plugins.values());
154
- }
155
-
156
- /**
157
- * Enter interactive mode
158
- */
159
- enterInteractiveMode(logger: Logger): void {
160
- this.isInteractiveMode = true;
161
- logger.info('🔧 Interactive CLI mode activated. Type /exit to quit, /help for commands.');
162
-
163
- // Set up browser console listener for interactive commands
164
- if (typeof window !== 'undefined') {
165
- this.setupBrowserInteractiveMode(logger);
166
- }
167
- }
168
-
169
- /**
170
- * Exit interactive mode
171
- */
172
- exitInteractiveMode(): void {
173
- this.isInteractiveMode = false;
174
- }
175
-
176
- /**
177
- * Setup browser interactive mode
178
- */
179
- private setupBrowserInteractiveMode(logger: Logger): void {
180
- // Add global CLI function for browser usage
181
- (window as any).cli = (commandString: string) => {
182
- return this.processCommand(`/${commandString}`, logger);
183
- };
184
-
185
- logger.info('💡 Use cli("command") to execute CLI commands in browser console.');
186
- }
187
-
188
- /**
189
- * Process a CLI command
190
- */
191
- async processCommand(commandString: string, logger: Logger): Promise<void> {
192
- if (!commandString.startsWith('/')) {
193
- logger.error('Invalid command. Commands must start with /');
194
- this.addToHistory(commandString, false);
195
- return;
196
- }
197
-
198
- const parts = commandString.slice(1).split(' ');
199
- const commandName = parts[0] || '';
200
- const args = parts.slice(1).join(' ');
201
-
202
- const command = this.getCommand(commandName);
203
- if (!command) {
204
- logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
205
-
206
- // Suggest similar commands
207
- const suggestions = this.getSuggestions(commandName);
208
- if (suggestions.length > 0) {
209
- logger.info(`📋 Did you mean: ${suggestions.slice(0, 3).join(', ')}?`);
210
- }
211
-
212
- this.addToHistory(commandString, false);
213
- return;
214
- }
215
-
216
- try {
217
- await command.execute(args || '', logger);
218
- this.addToHistory(commandString, true);
219
- } catch (error) {
220
- logger.error(`Command '${commandName}' failed:`, error);
221
- this.addToHistory(commandString, false);
222
- }
223
- }
224
-
225
- /**
226
- * Add command to history
227
- */
228
- private addToHistory(command: string, success: boolean): void {
229
- this.history.unshift({
230
- command,
231
- timestamp: new Date(),
232
- success
233
- });
234
-
235
- // Limit history size
236
- if (this.history.length > this.maxHistorySize) {
237
- this.history = this.history.slice(0, this.maxHistorySize);
238
- }
239
- }
240
-
241
- /**
242
- * Get command suggestions for partial matches
243
- */
244
- getSuggestions(partial: string): string[] {
245
- const commandNames = Array.from(this.commands.keys());
246
- return commandNames.filter(name => name.startsWith(partial));
247
- }
248
- }
@@ -1,93 +0,0 @@
1
- /**
2
- * @fileoverview Configuration commands for Advanced Logger CLI
3
- */
4
-
5
- import type { ICommand } from '../CommandProcessor.js';
6
- import type { Logger } from '../../Logger.js';
7
- import type { ThemeVariant, BannerType, Verbosity } from '../../types/index.js';
8
-
9
- /**
10
- * Configuration command handler
11
- */
12
- export class ConfigCommand implements ICommand {
13
- name = 'config';
14
- description = 'Show or update logger configuration';
15
- usage = '/config [json|key=value,...]';
16
-
17
- execute(args: string, logger: Logger): void {
18
- if (!args) {
19
- this.showStatus(logger);
20
- return;
21
- }
22
-
23
- try {
24
- // Try to parse as JSON first
25
- if (args.startsWith('{')) {
26
- const config = JSON.parse(args);
27
- this.applyConfig(config, logger);
28
- } else {
29
- // Parse key=value pairs
30
- const pairs = args.split(',').map(pair => pair.trim().split('='));
31
- const config: any = {};
32
- pairs.forEach(([key, value]) => {
33
- if (key && value) {
34
- config[key.trim()] = value.trim().replace(/["']/g, '');
35
- }
36
- });
37
- this.applyConfig(config, logger);
38
- }
39
- } catch (error) {
40
- logger.error('Invalid config format. Use JSON or key=value pairs:', error);
41
- logger.info('Examples: /config {"theme":"dark"} or /config theme=neon,verbosity=debug');
42
- }
43
- }
44
-
45
- private showStatus(logger: Logger): void {
46
- const statusData = {
47
- theme: logger.getConfig().theme || 'default',
48
- verbosity: logger.getConfig().verbosity,
49
- colors: logger.getConfig().enableColors,
50
- timestamps: logger.getConfig().enableTimestamps,
51
- stackTrace: logger.getConfig().enableStackTrace,
52
- globalPrefix: logger.getConfig().globalPrefix || 'none',
53
- bannerType: logger.getConfig().bannerType || 'simple',
54
- handlers: logger.getHandlers().length
55
- };
56
-
57
- logger.group('⚙️ Logger Configuration');
58
- logger.table(statusData);
59
- logger.groupEnd();
60
- }
61
-
62
- private applyConfig(config: any, logger: Logger): void {
63
- const validKeys = ['theme', 'verbosity', 'enableColors', 'enableTimestamps', 'enableStackTrace', 'globalPrefix', 'bannerType'];
64
- const applied: string[] = [];
65
-
66
- Object.entries(config).forEach(([key, value]) => {
67
- if (validKeys.includes(key)) {
68
- if (key === 'theme' && typeof value === 'string') {
69
- logger.setTheme(value as ThemeVariant);
70
- applied.push(`${key}=${value}`);
71
- } else if (key === 'bannerType' && typeof value === 'string') {
72
- logger.setBannerType(value as BannerType);
73
- applied.push(`${key}=${value}`);
74
- } else if (key === 'verbosity') {
75
- logger.setVerbosity(value as Verbosity);
76
- applied.push(`${key}=${value}`);
77
- } else if (key === 'globalPrefix') {
78
- logger.setGlobalPrefix(value as string);
79
- applied.push(`${key}=${value}`);
80
- } else {
81
- logger.updateConfig({ [key]: value });
82
- applied.push(`${key}=${value}`);
83
- }
84
- } else {
85
- logger.warn(`Invalid config key: ${key}`);
86
- }
87
- });
88
-
89
- if (applied.length > 0) {
90
- logger.success(`Configuration updated: ${applied.join(', ')}`);
91
- }
92
- }
93
- }