@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
package/dist/index.js ADDED
@@ -0,0 +1,627 @@
1
+ import { L as Logger } from "./chunks/Logger-D_vuKP4l.js";
2
+ import { A, B, C, e, H, c, S, a, T, b } from "./chunks/Logger-D_vuKP4l.js";
3
+ import { a as isNode, i as isBrowser, S as StylePresets, b as StyleBuilder } from "./chunks/environment-C1xxvc8l.js";
4
+ import { B as B2, D, E, T as T2, e as e2, f, g, p } from "./chunks/environment-C1xxvc8l.js";
5
+ import { A as A2, c as c2, f as f2, e as e3, d, b as b2, g as g2, k, i, n, m, l, a as a2, h, j, r, s } from "./chunks/color-converter-_Xdmsy7E.js";
6
+ import { s as safeSerialize } from "./chunks/formatting-DMJxYq9o.js";
7
+ import { B as B3, l as l2, m as m2, k as k2, n as n2, j as j2, o, e as e4, h as h2, i as i2, c as c3, d as d2, p as p2, q, r as r2 } from "./chunks/formatting-DMJxYq9o.js";
8
+ import { R } from "./chunks/RemoteLogHandler-CjWpWZGl.js";
9
+ import { j as j3, c as c4, a as a3, g as g3, b as b3, e as e5, d as d3, f as f3, h as h3, i as i3, p as p3, r as r3, s as s2 } from "./chunks/cli-module-Cx7qotPY.js";
10
+ class ConsoleTransport {
11
+ constructor(options) {
12
+ this.options = options;
13
+ }
14
+ name = "console";
15
+ write(record) {
16
+ const method = this.getConsoleMethod(record.level);
17
+ const prefix = record.prefix ? `[${record.prefix}] ` : "";
18
+ const location = record.location ? ` (${record.location.file}:${record.location.line})` : "";
19
+ console[method](`[${record.level.toUpperCase()}]${prefix} ${record.msg}${location}`);
20
+ }
21
+ getConsoleMethod(level) {
22
+ switch (level) {
23
+ case "debug":
24
+ return "log";
25
+ case "info":
26
+ return "info";
27
+ case "warn":
28
+ return "warn";
29
+ case "error":
30
+ case "critical":
31
+ return "error";
32
+ default:
33
+ return "log";
34
+ }
35
+ }
36
+ }
37
+ class FileTransport {
38
+ name = "file";
39
+ buffer = [];
40
+ flushTimer;
41
+ options;
42
+ constructor(options) {
43
+ this.options = options || {};
44
+ if (this.options.flushInterval) {
45
+ this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);
46
+ }
47
+ }
48
+ write(record) {
49
+ const line = JSON.stringify(record) + "\n";
50
+ this.buffer.push(line);
51
+ if (this.buffer.length >= (this.options.batchSize || 100)) {
52
+ this.flush();
53
+ }
54
+ }
55
+ async flush() {
56
+ if (this.buffer.length === 0) return;
57
+ const lines = this.buffer.join("");
58
+ this.buffer = [];
59
+ if (typeof globalThis.process !== "undefined" && typeof require === "function") {
60
+ try {
61
+ const fs = require("fs");
62
+ const dest = this.options.destination || "app.log";
63
+ fs.appendFileSync(dest, lines);
64
+ } catch {
65
+ }
66
+ }
67
+ }
68
+ close() {
69
+ if (this.flushTimer) {
70
+ clearInterval(this.flushTimer);
71
+ }
72
+ this.flush();
73
+ }
74
+ }
75
+ class HttpTransport {
76
+ name = "http";
77
+ buffer = [];
78
+ flushTimer;
79
+ options;
80
+ constructor(options) {
81
+ this.options = options || {};
82
+ if (this.options.flushInterval) {
83
+ this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);
84
+ }
85
+ }
86
+ write(record) {
87
+ this.buffer.push(record);
88
+ if (this.buffer.length >= (this.options.batchSize || 50)) {
89
+ this.flush();
90
+ }
91
+ }
92
+ async flush() {
93
+ if (this.buffer.length === 0 || !this.options.url) return;
94
+ const records = [...this.buffer];
95
+ this.buffer = [];
96
+ try {
97
+ await fetch(this.options.url, {
98
+ method: "POST",
99
+ headers: {
100
+ "Content-Type": "application/json",
101
+ ...this.options.headers
102
+ },
103
+ body: JSON.stringify({ logs: records })
104
+ });
105
+ } catch {
106
+ this.buffer.unshift(...records);
107
+ }
108
+ }
109
+ close() {
110
+ if (this.flushTimer) {
111
+ clearInterval(this.flushTimer);
112
+ }
113
+ this.flush();
114
+ }
115
+ }
116
+ class FileLogHandler {
117
+ filename;
118
+ maxSize;
119
+ fs;
120
+ // Node.js fs module
121
+ constructor(filename = "app.log", maxSize) {
122
+ this.filename = filename;
123
+ this.maxSize = maxSize;
124
+ if (isNode) {
125
+ try {
126
+ this.fs = require("fs");
127
+ } catch (error2) {
128
+ console.warn("FileLogHandler: Unable to load fs module:", error2);
129
+ }
130
+ }
131
+ }
132
+ handle(level, message, args, metadata) {
133
+ const logEntry = {
134
+ timestamp: metadata.timestamp,
135
+ level: level.toUpperCase(),
136
+ prefix: metadata.prefix,
137
+ message,
138
+ args: args.slice(1).map((arg) => safeSerialize(arg)),
139
+ location: metadata.stackInfo
140
+ };
141
+ const logLine = this.formatLogLine(logEntry);
142
+ if (isNode && this.fs) {
143
+ this.writeToFileNode(logLine);
144
+ } else if (isBrowser) {
145
+ this.writeToFileLocal(logLine);
146
+ } else {
147
+ console.log(`[FILE-LOG] ${logLine}`);
148
+ }
149
+ }
150
+ /**
151
+ * Format log entry as a single line for file storage
152
+ */
153
+ formatLogLine(entry) {
154
+ const parts = [
155
+ entry.timestamp,
156
+ `[${entry.level}]`,
157
+ entry.prefix ? `[${entry.prefix}]` : "",
158
+ entry.message
159
+ ].filter(Boolean);
160
+ let line = parts.join(" ");
161
+ if (entry.args && entry.args.length > 0) {
162
+ line += " " + entry.args.map(
163
+ (arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
164
+ ).join(" ");
165
+ }
166
+ if (entry.location) {
167
+ line += ` (${entry.location.file}:${entry.location.line}:${entry.location.column})`;
168
+ }
169
+ return line;
170
+ }
171
+ /**
172
+ * Write to actual file in Node.js environment
173
+ */
174
+ writeToFileNode(logLine) {
175
+ if (!this.fs) return;
176
+ try {
177
+ if (this.maxSize) {
178
+ try {
179
+ const stats = this.fs.statSync(this.filename);
180
+ if (stats.size > this.maxSize) {
181
+ const backupName = `${this.filename}.bak`;
182
+ this.fs.renameSync(this.filename, backupName);
183
+ }
184
+ } catch (error2) {
185
+ }
186
+ }
187
+ this.fs.appendFileSync(this.filename, logLine + "\n", "utf8");
188
+ } catch (error2) {
189
+ console.error("FileLogHandler: Failed to write to file:", error2);
190
+ }
191
+ }
192
+ /**
193
+ * Write to localStorage in browser environment
194
+ */
195
+ writeToFileLocal(logLine) {
196
+ try {
197
+ const storageKey = `logger_${this.filename}`;
198
+ const existingLogs = localStorage.getItem(storageKey) || "";
199
+ let newLogs = existingLogs;
200
+ if (existingLogs.length > 0) {
201
+ newLogs += "\n";
202
+ }
203
+ newLogs += logLine;
204
+ if (this.maxSize || newLogs.split("\n").length > 1e3) {
205
+ const lines = newLogs.split("\n");
206
+ const maxLines = this.maxSize ? Math.floor(this.maxSize / 100) : 1e3;
207
+ if (lines.length > maxLines) {
208
+ newLogs = lines.slice(-maxLines).join("\n");
209
+ }
210
+ }
211
+ localStorage.setItem(storageKey, newLogs);
212
+ } catch (error2) {
213
+ console.error("FileLogHandler: Failed to write to localStorage:", error2);
214
+ }
215
+ }
216
+ /**
217
+ * Get stored logs (useful for debugging)
218
+ */
219
+ getLogs() {
220
+ if (isNode && this.fs) {
221
+ try {
222
+ return this.fs.readFileSync(this.filename, "utf8");
223
+ } catch (error2) {
224
+ return null;
225
+ }
226
+ } else if (isBrowser) {
227
+ const storageKey = `logger_${this.filename}`;
228
+ return localStorage.getItem(storageKey);
229
+ }
230
+ return null;
231
+ }
232
+ /**
233
+ * Clear stored logs
234
+ */
235
+ clearLogs() {
236
+ if (isNode && this.fs) {
237
+ try {
238
+ this.fs.writeFileSync(this.filename, "", "utf8");
239
+ } catch (error2) {
240
+ console.error("FileLogHandler: Failed to clear file:", error2);
241
+ }
242
+ } else if (isBrowser) {
243
+ const storageKey = `logger_${this.filename}`;
244
+ localStorage.removeItem(storageKey);
245
+ }
246
+ }
247
+ }
248
+ class AnalyticsLogHandler {
249
+ handle(level, message, _args, metadata) {
250
+ if (level === "error" || level === "critical") {
251
+ console.debug("Analytics: Error tracked", {
252
+ level,
253
+ message,
254
+ timestamp: metadata.timestamp
255
+ });
256
+ }
257
+ }
258
+ }
259
+ const DEFAULT_CONFIG = {
260
+ maxEntries: 100,
261
+ ttl: 5 * 60 * 1e3,
262
+ enabled: true
263
+ };
264
+ class StyleCache {
265
+ cache = /* @__PURE__ */ new Map();
266
+ config;
267
+ hitCount = 0;
268
+ missCount = 0;
269
+ constructor(config = {}) {
270
+ this.config = { ...DEFAULT_CONFIG, ...config };
271
+ }
272
+ generateKey(key) {
273
+ return `${key.level}:${key.theme}:${key.presetName || "default"}:${key.hasPrefix}:${key.hasLocation}`;
274
+ }
275
+ get(key) {
276
+ if (!this.config.enabled) return null;
277
+ const cacheKey = this.generateKey(key);
278
+ const entry = this.cache.get(cacheKey);
279
+ if (!entry) {
280
+ this.missCount++;
281
+ return null;
282
+ }
283
+ if (Date.now() - entry.createdAt > this.config.ttl) {
284
+ this.cache.delete(cacheKey);
285
+ this.missCount++;
286
+ return null;
287
+ }
288
+ entry.hits++;
289
+ this.cache.delete(cacheKey);
290
+ this.cache.set(cacheKey, entry);
291
+ this.hitCount++;
292
+ return entry;
293
+ }
294
+ set(key, format, styles) {
295
+ if (!this.config.enabled) return;
296
+ const cacheKey = this.generateKey(key);
297
+ if (this.cache.size >= this.config.maxEntries) {
298
+ const firstKey = this.cache.keys().next().value;
299
+ if (firstKey) {
300
+ this.cache.delete(firstKey);
301
+ }
302
+ }
303
+ this.cache.set(cacheKey, {
304
+ format,
305
+ styles: [...styles],
306
+ createdAt: Date.now(),
307
+ hits: 0
308
+ });
309
+ }
310
+ clear() {
311
+ this.cache.clear();
312
+ this.hitCount = 0;
313
+ this.missCount = 0;
314
+ }
315
+ getStats() {
316
+ const total = this.hitCount + this.missCount;
317
+ return {
318
+ size: this.cache.size,
319
+ maxSize: this.config.maxEntries,
320
+ hitRate: total > 0 ? this.hitCount / total : 0,
321
+ hits: this.hitCount,
322
+ misses: this.missCount
323
+ };
324
+ }
325
+ setEnabled(enabled) {
326
+ this.config.enabled = enabled;
327
+ if (!enabled) {
328
+ this.clear();
329
+ }
330
+ }
331
+ isEnabled() {
332
+ return this.config.enabled;
333
+ }
334
+ }
335
+ let _styleCache = null;
336
+ function getStyleCache() {
337
+ if (!_styleCache) {
338
+ _styleCache = new StyleCache();
339
+ }
340
+ return _styleCache;
341
+ }
342
+ class BufferWriter {
343
+ buffer = [];
344
+ maxSize;
345
+ /**
346
+ * Creates a new BufferWriter
347
+ * @param maxSize - Maximum number of entries to buffer (default: 1000)
348
+ */
349
+ constructor(maxSize = 1e3) {
350
+ this.maxSize = maxSize;
351
+ }
352
+ /**
353
+ * Writes a log entry to the buffer
354
+ * @param message - Formatted log message
355
+ * @param level - Log level
356
+ * @param styles - CSS styles (for browser console)
357
+ */
358
+ write(message, level, styles) {
359
+ if (this.buffer.length >= this.maxSize) {
360
+ this.buffer.shift();
361
+ }
362
+ this.buffer.push({
363
+ message,
364
+ level,
365
+ styles,
366
+ timestamp: Date.now()
367
+ });
368
+ }
369
+ /**
370
+ * Returns all buffered entries
371
+ * @returns Copy of the buffer array
372
+ */
373
+ getBuffer() {
374
+ return [...this.buffer];
375
+ }
376
+ /**
377
+ * Returns buffered entries filtered by log level
378
+ * @param levels - Log levels to include
379
+ * @returns Filtered buffer entries
380
+ */
381
+ getByLevel(...levels) {
382
+ return this.buffer.filter((entry) => levels.includes(entry.level));
383
+ }
384
+ /**
385
+ * Returns the number of buffered entries
386
+ */
387
+ get size() {
388
+ return this.buffer.length;
389
+ }
390
+ /**
391
+ * Checks if buffer is empty
392
+ */
393
+ get isEmpty() {
394
+ return this.buffer.length === 0;
395
+ }
396
+ /**
397
+ * Clears all buffered entries
398
+ */
399
+ clear() {
400
+ this.buffer = [];
401
+ }
402
+ /**
403
+ * Outputs all buffered entries to console and clears the buffer
404
+ */
405
+ flush() {
406
+ this.buffer.forEach((entry) => {
407
+ if (entry.styles.length > 0) {
408
+ console.log(entry.message, ...entry.styles);
409
+ } else {
410
+ console.log(entry.message);
411
+ }
412
+ });
413
+ this.clear();
414
+ }
415
+ /**
416
+ * Outputs buffered entries to console without clearing
417
+ */
418
+ replay() {
419
+ this.buffer.forEach((entry) => {
420
+ if (entry.styles.length > 0) {
421
+ console.log(entry.message, ...entry.styles);
422
+ } else {
423
+ console.log(entry.message);
424
+ }
425
+ });
426
+ }
427
+ /**
428
+ * Returns all messages as an array of strings
429
+ */
430
+ toArray() {
431
+ return this.buffer.map((entry) => entry.message);
432
+ }
433
+ /**
434
+ * Returns all messages joined as a single string
435
+ * @param separator - String to join messages with (default: newline)
436
+ */
437
+ toString(separator = "\n") {
438
+ return this.toArray().join(separator);
439
+ }
440
+ }
441
+ let _logger = null;
442
+ function getLogger() {
443
+ if (!_logger) {
444
+ _logger = new Logger();
445
+ }
446
+ return _logger;
447
+ }
448
+ const index = getLogger();
449
+ const debug = (...args) => getLogger().debug(...args);
450
+ const info = (...args) => getLogger().info(...args);
451
+ const warn = (...args) => getLogger().warn(...args);
452
+ const error = (...args) => getLogger().error(...args);
453
+ const success = (...args) => getLogger().success(...args);
454
+ const critical = (...args) => getLogger().critical(...args);
455
+ const trace = (...args) => getLogger().trace(...args);
456
+ const table = (data, columns) => getLogger().table(data, columns);
457
+ const group = (label, collapsed) => getLogger().group(label, collapsed);
458
+ const groupEnd = () => getLogger().groupEnd();
459
+ const time = (label) => getLogger().time(label);
460
+ const timeEnd = (label) => getLogger().timeEnd(label);
461
+ const setGlobalPrefix = (prefix) => getLogger().setGlobalPrefix(prefix);
462
+ const scope = (name) => getLogger().scope(name);
463
+ const component = (name) => getLogger().component(name);
464
+ const api = (name) => getLogger().api(name);
465
+ const badges = (badgeList) => getLogger().badges(badgeList);
466
+ const badge = (badgeName) => getLogger().badge(badgeName);
467
+ const clearBadges = () => getLogger().clearBadges();
468
+ const setVerbosity = (level) => getLogger().setVerbosity(level);
469
+ const addHandler = (handler) => getLogger().addHandler(handler);
470
+ const setTheme = (theme) => getLogger().setTheme(theme);
471
+ const setBannerType = (bannerType) => getLogger().setBannerType(bannerType);
472
+ const showBanner = (bannerType) => getLogger().showBanner(bannerType);
473
+ const logWithSVG = (message, svgContent, options) => getLogger().logWithSVG(message, svgContent, options);
474
+ const logAnimated = (message, duration) => getLogger().logAnimated(message, duration);
475
+ const cli = (command) => getLogger().cli(command);
476
+ const step = (current, total, message) => getLogger().step(current, total, message);
477
+ const spinner = (message) => getLogger().spinner(message);
478
+ const box = (content, options) => getLogger().box(content, options);
479
+ const cliTable = (rows, options) => getLogger().cliTable(rows, options);
480
+ const header = (title, subtitle) => getLogger().header(title, subtitle);
481
+ const divider = () => getLogger().divider();
482
+ const blank = () => getLogger().blank();
483
+ const setCLILevel = (level) => getLogger().setCLILevel(level);
484
+ const addSerializer = (type, serializer, priority) => getLogger().addSerializer(type, serializer, priority);
485
+ const removeSerializer = (type) => getLogger().removeSerializer(type);
486
+ const on = (event, callback, priority) => getLogger().on(event, callback, priority);
487
+ const once = (event, callback, priority) => getLogger().once(event, callback, priority);
488
+ const off = (event, callback) => getLogger().off(event, callback);
489
+ const use = (middleware, priority) => getLogger().use(middleware, priority);
490
+ const addTransport = (target) => getLogger().addTransport(target);
491
+ const removeTransport = (id) => getLogger().removeTransport(id);
492
+ const flushTransports = () => getLogger().flushTransports();
493
+ const closeTransports = () => getLogger().closeTransports();
494
+ const createStyle = () => new StyleBuilder();
495
+ const stylePresets = {
496
+ success: StylePresets.success().build(),
497
+ error: StylePresets.error().build(),
498
+ warning: StylePresets.warning().build(),
499
+ info: StylePresets.info().build(),
500
+ accent: StylePresets.accent().build()
501
+ };
502
+ export {
503
+ A2 as ANSI,
504
+ A as APILogger,
505
+ AnalyticsLogHandler,
506
+ B as BANNER_VARIANTS,
507
+ B3 as BUILD_FORMATTERS,
508
+ B2 as BUILD_PRESETS,
509
+ BufferWriter,
510
+ C as ComponentLogger,
511
+ ConsoleTransport,
512
+ e as ContextLogger,
513
+ D as DEFAULT_CONFIG,
514
+ E as ENVIRONMENT_DETECTION,
515
+ FileLogHandler,
516
+ FileTransport,
517
+ H as HookManager,
518
+ HttpTransport,
519
+ Logger,
520
+ R as RemoteLogHandler,
521
+ c as ScopedLogger,
522
+ S as SerializerRegistry,
523
+ StyleBuilder,
524
+ StyleCache,
525
+ StylePresets,
526
+ a as THEME_BANNERS,
527
+ T as THEME_PRESETS,
528
+ T2 as TerminalRenderer,
529
+ b as TransportManager,
530
+ addHandler,
531
+ addSerializer,
532
+ addTransport,
533
+ l2 as ansiBackground,
534
+ m2 as ansiBold,
535
+ k2 as ansiColor,
536
+ n2 as ansiDim,
537
+ j2 as ansiStyle,
538
+ o as ansiUnderline,
539
+ api,
540
+ j3 as applyLogOptions,
541
+ badge,
542
+ badges,
543
+ blank,
544
+ box,
545
+ clearBadges,
546
+ cli,
547
+ cliTable,
548
+ closeTransports,
549
+ c2 as colorToHex,
550
+ component,
551
+ e4 as createANSIOutput,
552
+ h2 as createBuildOutput,
553
+ i2 as createCIOutput,
554
+ c3 as createOutput,
555
+ createStyle,
556
+ critical,
557
+ f2 as cssColorToANSI,
558
+ debug,
559
+ index as default,
560
+ e2 as detectEnvironmentPreset,
561
+ d2 as detectOptimalFormat,
562
+ divider,
563
+ error,
564
+ flushTransports,
565
+ c4 as formatBadge,
566
+ a3 as formatColumns,
567
+ g3 as formatElapsedTime,
568
+ b3 as formatKeyValue,
569
+ p2 as formatLogLevelANSI,
570
+ e5 as formatRelativeTime,
571
+ q as formatSuccessANSI,
572
+ f as formatTimestamp,
573
+ d3 as formatTimestampExt,
574
+ f3 as formatWithRightAlign,
575
+ e3 as getANSI256Background,
576
+ d as getANSI256Foreground,
577
+ b2 as getANSIBackground,
578
+ g2 as getANSIForeground,
579
+ k as getColorCapability,
580
+ i as getEnvironment,
581
+ n as getEnvironmentInfo,
582
+ g as getOptimalConfig,
583
+ getStyleCache,
584
+ m as getTerminalHeight,
585
+ l as getTerminalWidth,
586
+ h3 as getVisibleLength,
587
+ group,
588
+ groupEnd,
589
+ header,
590
+ a2 as hexTo256,
591
+ h as hexToRgb,
592
+ info,
593
+ i3 as isKeyValueObject,
594
+ j as isRunningInTerminal,
595
+ logAnimated,
596
+ logWithSVG,
597
+ off,
598
+ on,
599
+ once,
600
+ p3 as padToWidth,
601
+ p as parseStackTrace,
602
+ removeSerializer,
603
+ removeTransport,
604
+ r3 as resetStartTime,
605
+ r as rgbToHex,
606
+ r2 as sanitizeEmojis,
607
+ scope,
608
+ setBannerType,
609
+ setCLILevel,
610
+ setGlobalPrefix,
611
+ setTheme,
612
+ setVerbosity,
613
+ showBanner,
614
+ spinner,
615
+ step,
616
+ s2 as stripAnsi,
617
+ stylePresets,
618
+ success,
619
+ s as supportsANSI,
620
+ table,
621
+ time,
622
+ timeEnd,
623
+ trace,
624
+ use,
625
+ warn
626
+ };
627
+ //# sourceMappingURL=index.js.map