@mks2508/better-logger 0.0.2-alpha.2 → 0.11.0-alpha.1

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 (247) hide show
  1. package/.github/workflows/ci-quality.yml +357 -0
  2. package/.github/workflows/docs-demo.yml +119 -0
  3. package/.github/workflows/releases-core.yml +512 -0
  4. package/.github/workflows/releases-full.yml +582 -0
  5. package/.github/{workflows → workflows-backup}/ci.yml +12 -110
  6. package/.github/workflows-backup/nightly.yml +196 -0
  7. package/.github/workflows-backup/release-optimized.yml +373 -0
  8. package/.release-notes-0.2.0.md +129 -0
  9. package/.yamllint +28 -0
  10. package/CHANGELOG.json +749 -0
  11. package/CLAUDE.md +92 -1
  12. package/README.md +142 -498
  13. package/bun.lock +323 -0
  14. package/demo.html +9 -2
  15. package/dist/Logger.d.ts +176 -0
  16. package/dist/Logger.d.ts.map +1 -0
  17. package/dist/Logger.js +498 -0
  18. package/dist/chunks/Logger-C2-cR3No.js +2 -0
  19. package/dist/chunks/Logger-C2-cR3No.js.map +1 -0
  20. package/dist/chunks/Logger-CVwk8cgA.js +2159 -0
  21. package/dist/chunks/Logger-CVwk8cgA.js.map +1 -0
  22. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  23. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  24. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  25. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  26. package/dist/chunks/StyleBuilder-BoJTmskd.js +361 -0
  27. package/dist/chunks/StyleBuilder-BoJTmskd.js.map +1 -0
  28. package/dist/chunks/StyleBuilder-LPLzsoHY.js +4 -0
  29. package/dist/chunks/StyleBuilder-LPLzsoHY.js.map +1 -0
  30. package/dist/cli/CommandProcessor.d.ts +103 -0
  31. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  32. package/dist/cli/CommandProcessor.js +184 -0
  33. package/dist/cli/commands/ConfigCommand.d.ts +17 -0
  34. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/ConfigCommand.js +88 -0
  36. package/dist/cli/commands/ExportCommand.d.ts +51 -0
  37. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  38. package/dist/cli/commands/ExportCommand.js +243 -0
  39. package/dist/cli/commands/HistoryCommand.d.ts +50 -0
  40. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  41. package/dist/cli/commands/HistoryCommand.js +96 -0
  42. package/dist/cli/commands/StatusCommand.d.ts +33 -0
  43. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  44. package/dist/cli/commands/StatusCommand.js +93 -0
  45. package/dist/cli/commands/ThemeCommand.d.ts +33 -0
  46. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/ThemeCommand.js +79 -0
  48. package/dist/cli/help.d.ts +15 -0
  49. package/dist/cli/help.d.ts.map +1 -0
  50. package/dist/cli/help.js +118 -0
  51. package/dist/cli/index.d.ts +15 -0
  52. package/dist/cli/index.d.ts.map +1 -0
  53. package/dist/cli/index.js +46 -0
  54. package/dist/constants.d.ts +91 -0
  55. package/dist/constants.d.ts.map +1 -0
  56. package/dist/constants.js +80 -0
  57. package/dist/core.cjs +1 -1
  58. package/dist/core.cjs.map +1 -1
  59. package/dist/core.d.ts +130 -0
  60. package/dist/core.d.ts.map +1 -0
  61. package/dist/core.js +258 -242
  62. package/dist/core.js.map +1 -1
  63. package/dist/example.d.ts +18 -0
  64. package/dist/example.d.ts.map +1 -0
  65. package/dist/example.js +154 -0
  66. package/dist/exports-module.d.ts +203 -0
  67. package/dist/exports-module.d.ts.map +1 -0
  68. package/dist/exports-module.js +260 -0
  69. package/dist/exports.cjs +1 -1
  70. package/dist/exports.cjs.map +1 -1
  71. package/dist/exports.js +2 -2
  72. package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
  73. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  74. package/dist/handlers/AnalyticsLogHandler.js +19 -0
  75. package/dist/handlers/ExportLogHandler.d.ts +103 -0
  76. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  77. package/dist/handlers/ExportLogHandler.js +516 -0
  78. package/dist/handlers/FileLogHandler.d.ts +13 -0
  79. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  80. package/dist/handlers/FileLogHandler.js +24 -0
  81. package/dist/handlers/RemoteLogHandler.d.ts +14 -0
  82. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  83. package/dist/handlers/RemoteLogHandler.js +37 -0
  84. package/dist/handlers/index.d.ts +8 -0
  85. package/dist/handlers/index.d.ts.map +1 -0
  86. package/dist/handlers/index.js +7 -0
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.d.ts +86 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +89 -103
  92. package/dist/main.d.ts +2 -0
  93. package/dist/main.d.ts.map +1 -0
  94. package/dist/main.js +139 -0
  95. package/dist/styling/StyleBuilder.d.ts +132 -0
  96. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  97. package/dist/styling/StyleBuilder.js +268 -0
  98. package/dist/styling/banners.d.ts +45 -0
  99. package/dist/styling/banners.d.ts.map +1 -0
  100. package/dist/styling/banners.js +155 -0
  101. package/dist/styling/index.d.ts +7 -0
  102. package/dist/styling/index.d.ts.map +1 -0
  103. package/dist/styling/index.js +6 -0
  104. package/dist/styling/themes.d.ts +10 -0
  105. package/dist/styling/themes.d.ts.map +1 -0
  106. package/dist/styling/themes.js +231 -0
  107. package/dist/styling-module.d.ts +185 -0
  108. package/dist/styling-module.d.ts.map +1 -0
  109. package/dist/styling-module.js +199 -0
  110. package/dist/styling.cjs +1 -1
  111. package/dist/styling.cjs.map +1 -1
  112. package/dist/styling.js +4 -4
  113. package/dist/types/Logger.d.ts +172 -0
  114. package/dist/types/Logger.d.ts.map +1 -0
  115. package/dist/types/cli/CommandProcessor.d.ts +100 -0
  116. package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
  117. package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
  118. package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
  119. package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
  120. package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
  121. package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
  122. package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
  123. package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
  124. package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
  125. package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
  126. package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
  127. package/dist/types/cli/help.d.ts +12 -0
  128. package/dist/types/cli/help.d.ts.map +1 -0
  129. package/dist/types/cli/index.d.ts +15 -0
  130. package/dist/types/cli/index.d.ts.map +1 -0
  131. package/dist/types/constants.d.ts +88 -0
  132. package/dist/types/constants.d.ts.map +1 -0
  133. package/dist/types/core.d.ts +71 -211
  134. package/dist/types/core.d.ts.map +1 -0
  135. package/dist/types/core.js +13 -0
  136. package/dist/types/example.d.ts +18 -0
  137. package/dist/types/example.d.ts.map +1 -0
  138. package/dist/types/exports-module.d.ts +196 -0
  139. package/dist/types/exports-module.d.ts.map +1 -0
  140. package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
  141. package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  142. package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
  143. package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
  144. package/dist/types/handlers/FileLogHandler.d.ts +10 -0
  145. package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
  146. package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
  147. package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
  148. package/dist/types/handlers/index.d.ts +8 -0
  149. package/dist/types/handlers/index.d.ts.map +1 -0
  150. package/dist/types/handlers.d.ts +88 -0
  151. package/dist/types/handlers.d.ts.map +1 -0
  152. package/dist/types/handlers.js +4 -0
  153. package/dist/types/index.d.ts +7 -675
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/dist/types/index.js +4 -0
  156. package/dist/types/main.d.ts +2 -0
  157. package/dist/types/main.d.ts.map +1 -0
  158. package/dist/types/styling/StyleBuilder.d.ts +132 -0
  159. package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
  160. package/dist/types/styling/banners.d.ts +42 -0
  161. package/dist/types/styling/banners.d.ts.map +1 -0
  162. package/dist/types/styling/index.d.ts +7 -0
  163. package/dist/types/styling/index.d.ts.map +1 -0
  164. package/dist/types/styling/themes.d.ts +7 -0
  165. package/dist/types/styling/themes.d.ts.map +1 -0
  166. package/dist/types/styling-module.d.ts +178 -0
  167. package/dist/types/styling-module.d.ts.map +1 -0
  168. package/dist/types/types/core.d.ts +71 -0
  169. package/dist/types/types/core.d.ts.map +1 -0
  170. package/dist/types/types/handlers.d.ts +85 -0
  171. package/dist/types/types/handlers.d.ts.map +1 -0
  172. package/dist/types/types/index.d.ts +7 -0
  173. package/dist/types/types/index.d.ts.map +1 -0
  174. package/dist/types/utils/index.d.ts +7 -0
  175. package/dist/types/utils/index.d.ts.map +1 -0
  176. package/dist/types/utils/output.d.ts +29 -0
  177. package/dist/types/utils/output.d.ts.map +1 -0
  178. package/dist/types/utils/stackTrace.d.ts +6 -0
  179. package/dist/types/utils/stackTrace.d.ts.map +1 -0
  180. package/dist/types/utils/timestamps.d.ts +20 -0
  181. package/dist/types/utils/timestamps.d.ts.map +1 -0
  182. package/dist/utils/index.d.ts +7 -0
  183. package/dist/utils/index.d.ts.map +1 -0
  184. package/dist/utils/index.js +6 -0
  185. package/dist/utils/output.d.ts +32 -0
  186. package/dist/utils/output.d.ts.map +1 -0
  187. package/dist/utils/output.js +97 -0
  188. package/dist/utils/stackTrace.d.ts +9 -0
  189. package/dist/utils/stackTrace.d.ts.map +1 -0
  190. package/dist/utils/stackTrace.js +81 -0
  191. package/dist/utils/timestamps.d.ts +20 -0
  192. package/dist/utils/timestamps.d.ts.map +1 -0
  193. package/dist/utils/timestamps.js +71 -0
  194. package/docs/API.md +691 -0
  195. package/docs/DEVELOPMENT.md +731 -0
  196. package/docs/PACKAGES.md +244 -0
  197. package/docs/_config.yml +36 -0
  198. package/docs/index.md +179 -0
  199. package/examples/README.md +208 -0
  200. package/examples/basic-logging.js +75 -0
  201. package/examples/data-export.js +234 -0
  202. package/examples/package.json +16 -0
  203. package/examples/performance-timing.js +170 -0
  204. package/examples/styling-themes.js +207 -0
  205. package/package.json +32 -21
  206. package/packages/core/package.json +35 -0
  207. package/packages/exports/package.json +41 -0
  208. package/packages/styling/package.json +41 -0
  209. package/project-utils/README.md +172 -0
  210. package/project-utils/auto-release-gemini.ts +1193 -0
  211. package/project-utils/commit-generator.ts +1385 -0
  212. package/project-utils/commit-ui.ts +264 -0
  213. package/project-utils/git-utils.ts +199 -0
  214. package/project-utils/github-release-manager.ts +466 -0
  215. package/project-utils/prompt-templates.js +345 -0
  216. package/project-utils/prompt-templates.ts +422 -0
  217. package/project-utils/version-manager.ts +1078 -0
  218. package/src/Logger.ts +2 -1
  219. package/src/cli/CommandProcessor.ts +173 -2
  220. package/src/cli/commands/HistoryCommand.ts +117 -0
  221. package/src/cli/index.ts +12 -0
  222. package/src/handlers/ExportLogHandler.ts +141 -0
  223. package/tests/test-conflict-resolution.ts +391 -0
  224. package/tests/validate-workflows.sh +131 -0
  225. package/tests/yaml-autofix.sh +146 -0
  226. package/vite.config.ts +152 -50
  227. package/.claude/settings.local.json +0 -22
  228. package/.npmrc.bak +0 -1
  229. package/dist/chunks/Logger-BQhMKy_T.js +0 -2
  230. package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
  231. package/dist/chunks/Logger-BrFKFZcD.js +0 -978
  232. package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
  233. package/dist/chunks/core-2opW4Pi3.js +0 -194
  234. package/dist/chunks/core-2opW4Pi3.js.map +0 -1
  235. package/dist/chunks/core-DyugwSYZ.js +0 -4
  236. package/dist/chunks/core-DyugwSYZ.js.map +0 -1
  237. package/dist/chunks/exports-BNP3R7dp.js +0 -421
  238. package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
  239. package/dist/chunks/exports-U1xLBXrY.js +0 -2
  240. package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
  241. package/dist/chunks/styling-DhUDzwlE.js +0 -654
  242. package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
  243. package/dist/chunks/styling-tmRDI28D.js +0 -2
  244. package/dist/chunks/styling-tmRDI28D.js.map +0 -1
  245. package/dist/types/exports.d.ts +0 -600
  246. package/dist/types/styling.d.ts +0 -751
  247. /package/.github/{workflows → workflows-backup}/release.yml +0 -0
@@ -0,0 +1,2159 @@
1
+ import { f as formatTimestamp, a as StyleBuilder, B as BUFFER_LIMITS, b as parseTimeInput, c as formatDisplayTime, E as EXPORT_FORMATS, D as DEFAULT_CONFIG, p as parseStackTrace, S as StylePresets } from "./StyleBuilder-BoJTmskd.js";
2
+ const THEME_PRESETS = {
3
+ default: {
4
+ debug: {
5
+ emoji: "🐞",
6
+ label: "DEBUG",
7
+ background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
8
+ color: "#ffffff",
9
+ border: "1px solid #667eea",
10
+ shadow: "0 2px 4px rgba(102, 126, 234, 0.3)"
11
+ },
12
+ info: {
13
+ emoji: "ℹ️",
14
+ label: "INFO",
15
+ background: "linear-gradient(135deg, #74b9ff 0%, #0984e3 100%)",
16
+ color: "#ffffff",
17
+ border: "1px solid #74b9ff",
18
+ shadow: "0 2px 4px rgba(116, 185, 255, 0.3)"
19
+ },
20
+ warn: {
21
+ emoji: "⚠️",
22
+ label: "WARN",
23
+ background: "linear-gradient(135deg, #fdcb6e 0%, #e17055 100%)",
24
+ color: "#2d3436",
25
+ border: "1px solid #fdcb6e",
26
+ shadow: "0 2px 4px rgba(253, 203, 110, 0.3)"
27
+ },
28
+ error: {
29
+ emoji: "❌",
30
+ label: "ERROR",
31
+ background: "linear-gradient(135deg, #e84393 0%, #d63031 100%)",
32
+ color: "#ffffff",
33
+ border: "1px solid #e84393",
34
+ shadow: "0 2px 4px rgba(232, 67, 147, 0.3)"
35
+ },
36
+ success: {
37
+ emoji: "✅",
38
+ label: "SUCCESS",
39
+ background: "linear-gradient(135deg, #00b894 0%, #00a085 100%)",
40
+ color: "#ffffff",
41
+ border: "1px solid #00b894",
42
+ shadow: "0 2px 4px rgba(0, 184, 148, 0.3)"
43
+ },
44
+ critical: {
45
+ emoji: "🔥",
46
+ label: "CRITICAL",
47
+ background: "linear-gradient(135deg, #ff3838 0%, #ff1744 100%)",
48
+ color: "#ffffff",
49
+ border: "2px solid #ff3838",
50
+ shadow: "0 4px 8px rgba(255, 56, 56, 0.5)"
51
+ }
52
+ },
53
+ dark: {
54
+ debug: {
55
+ emoji: "🌙",
56
+ label: "DEBUG",
57
+ background: "linear-gradient(135deg, #2d3748 0%, #4a5568 100%)",
58
+ color: "#e2e8f0",
59
+ border: "1px solid #4a5568",
60
+ shadow: "0 2px 4px rgba(45, 55, 72, 0.8)"
61
+ },
62
+ info: {
63
+ emoji: "💡",
64
+ label: "INFO",
65
+ background: "linear-gradient(135deg, #1a202c 0%, #2d3748 100%)",
66
+ color: "#90cdf4",
67
+ border: "1px solid #3182ce",
68
+ shadow: "0 2px 4px rgba(26, 32, 44, 0.8)"
69
+ },
70
+ warn: {
71
+ emoji: "⚡",
72
+ label: "WARN",
73
+ background: "linear-gradient(135deg, #744210 0%, #975a16 100%)",
74
+ color: "#faf089",
75
+ border: "1px solid #d69e2e",
76
+ shadow: "0 2px 4px rgba(116, 66, 16, 0.8)"
77
+ },
78
+ error: {
79
+ emoji: "💀",
80
+ label: "ERROR",
81
+ background: "linear-gradient(135deg, #742a2a 0%, #9b2c2c 100%)",
82
+ color: "#feb2b2",
83
+ border: "1px solid #e53e3e",
84
+ shadow: "0 2px 4px rgba(116, 42, 42, 0.8)"
85
+ },
86
+ success: {
87
+ emoji: "🎯",
88
+ label: "SUCCESS",
89
+ background: "linear-gradient(135deg, #276749 0%, #2f855a 100%)",
90
+ color: "#9ae6b4",
91
+ border: "1px solid #38a169",
92
+ shadow: "0 2px 4px rgba(39, 103, 73, 0.8)"
93
+ },
94
+ critical: {
95
+ emoji: "💥",
96
+ label: "CRITICAL",
97
+ background: "linear-gradient(135deg, #1a1a1a 0%, #ff0000 100%)",
98
+ color: "#ffffff",
99
+ border: "2px solid #ff0000",
100
+ shadow: "0 4px 8px rgba(255, 0, 0, 0.9)"
101
+ }
102
+ },
103
+ neon: {
104
+ debug: {
105
+ emoji: "⚡",
106
+ label: "DEBUG",
107
+ background: "linear-gradient(135deg, #0f3460 0%, #e94560 100%)",
108
+ color: "#00ffff",
109
+ border: "1px solid #00ffff",
110
+ shadow: "0 0 10px rgba(0, 255, 255, 0.5)"
111
+ },
112
+ info: {
113
+ emoji: "🔮",
114
+ label: "INFO",
115
+ background: "linear-gradient(135deg, #16213e 0%, #0f3460 100%)",
116
+ color: "#00ff41",
117
+ border: "1px solid #00ff41",
118
+ shadow: "0 0 10px rgba(0, 255, 65, 0.5)"
119
+ },
120
+ warn: {
121
+ emoji: "⚠️",
122
+ label: "WARN",
123
+ background: "linear-gradient(135deg, #533a03 0%, #e94560 100%)",
124
+ color: "#ffff00",
125
+ border: "1px solid #ffff00",
126
+ shadow: "0 0 10px rgba(255, 255, 0, 0.5)"
127
+ },
128
+ error: {
129
+ emoji: "💥",
130
+ label: "ERROR",
131
+ background: "linear-gradient(135deg, #5c0a0a 0%, #ff073a 100%)",
132
+ color: "#ff073a",
133
+ border: "1px solid #ff073a",
134
+ shadow: "0 0 10px rgba(255, 7, 58, 0.8)"
135
+ },
136
+ success: {
137
+ emoji: "✨",
138
+ label: "SUCCESS",
139
+ background: "linear-gradient(135deg, #0a5c0a 0%, #39ff14 100%)",
140
+ color: "#39ff14",
141
+ border: "1px solid #39ff14",
142
+ shadow: "0 0 10px rgba(57, 255, 20, 0.8)"
143
+ },
144
+ critical: {
145
+ emoji: "🌟",
146
+ label: "CRITICAL",
147
+ background: "linear-gradient(135deg, #000000 0%, #ff0080 100%)",
148
+ color: "#ff0080",
149
+ border: "2px solid #ff0080",
150
+ shadow: "0 0 20px rgba(255, 0, 128, 1)"
151
+ }
152
+ },
153
+ minimal: {
154
+ debug: {
155
+ emoji: "",
156
+ label: "DEBUG",
157
+ background: "#f7fafc",
158
+ color: "#4a5568",
159
+ border: "1px solid #e2e8f0",
160
+ shadow: "none"
161
+ },
162
+ info: {
163
+ emoji: "",
164
+ label: "INFO",
165
+ background: "#ebf8ff",
166
+ color: "#2b6cb0",
167
+ border: "1px solid #bee3f8",
168
+ shadow: "none"
169
+ },
170
+ warn: {
171
+ emoji: "",
172
+ label: "WARN",
173
+ background: "#fffbf0",
174
+ color: "#c05621",
175
+ border: "1px solid #fed7aa",
176
+ shadow: "none"
177
+ },
178
+ error: {
179
+ emoji: "",
180
+ label: "ERROR",
181
+ background: "#fef5f5",
182
+ color: "#c53030",
183
+ border: "1px solid #fca5a5",
184
+ shadow: "none"
185
+ },
186
+ success: {
187
+ emoji: "",
188
+ label: "SUCCESS",
189
+ background: "#f0fff4",
190
+ color: "#2f855a",
191
+ border: "1px solid #9ae6b4",
192
+ shadow: "none"
193
+ },
194
+ critical: {
195
+ emoji: "",
196
+ label: "CRITICAL",
197
+ background: "#fef5f5",
198
+ color: "#e53e3e",
199
+ border: "2px solid #f56565",
200
+ shadow: "none"
201
+ }
202
+ },
203
+ // Additional theme variants can be added here
204
+ light: {
205
+ debug: {
206
+ emoji: "🔍",
207
+ label: "DEBUG",
208
+ background: "linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%)",
209
+ color: "#1565c0",
210
+ border: "1px solid #90caf9",
211
+ shadow: "0 1px 3px rgba(33, 150, 243, 0.2)"
212
+ },
213
+ info: {
214
+ emoji: "ℹ️",
215
+ label: "INFO",
216
+ background: "linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%)",
217
+ color: "#7b1fa2",
218
+ border: "1px solid #ce93d8",
219
+ shadow: "0 1px 3px rgba(156, 39, 176, 0.2)"
220
+ },
221
+ warn: {
222
+ emoji: "⚠️",
223
+ label: "WARN",
224
+ background: "linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%)",
225
+ color: "#f57c00",
226
+ border: "1px solid #ffcc02",
227
+ shadow: "0 1px 3px rgba(255, 152, 0, 0.2)"
228
+ },
229
+ error: {
230
+ emoji: "❌",
231
+ label: "ERROR",
232
+ background: "linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%)",
233
+ color: "#d32f2f",
234
+ border: "1px solid #f44336",
235
+ shadow: "0 1px 3px rgba(244, 67, 54, 0.2)"
236
+ },
237
+ success: {
238
+ emoji: "✅",
239
+ label: "SUCCESS",
240
+ background: "linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%)",
241
+ color: "#388e3c",
242
+ border: "1px solid #4caf50",
243
+ shadow: "0 1px 3px rgba(76, 175, 80, 0.2)"
244
+ },
245
+ critical: {
246
+ emoji: "🚨",
247
+ label: "CRITICAL",
248
+ background: "linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%)",
249
+ color: "#c2185b",
250
+ border: "2px solid #e91e63",
251
+ shadow: "0 2px 6px rgba(233, 30, 99, 0.3)"
252
+ }
253
+ },
254
+ cyberpunk: {
255
+ debug: {
256
+ emoji: "🤖",
257
+ label: "DEBUG",
258
+ background: "linear-gradient(135deg, #0d1b2a 0%, #415a77 100%)",
259
+ color: "#00d4aa",
260
+ border: "1px solid #00d4aa",
261
+ shadow: "0 0 15px rgba(0, 212, 170, 0.4)"
262
+ },
263
+ info: {
264
+ emoji: "🔗",
265
+ label: "INFO",
266
+ background: "linear-gradient(135deg, #1b263b 0%, #0d1b2a 100%)",
267
+ color: "#00b4d8",
268
+ border: "1px solid #00b4d8",
269
+ shadow: "0 0 15px rgba(0, 180, 216, 0.4)"
270
+ },
271
+ warn: {
272
+ emoji: "⚡",
273
+ label: "WARN",
274
+ background: "linear-gradient(135deg, #f72585 0%, #b5179e 100%)",
275
+ color: "#ffff3f",
276
+ border: "1px solid #ffff3f",
277
+ shadow: "0 0 15px rgba(255, 255, 63, 0.4)"
278
+ },
279
+ error: {
280
+ emoji: "💀",
281
+ label: "ERROR",
282
+ background: "linear-gradient(135deg, #7209b7 0%, #480ca8 100%)",
283
+ color: "#ff006e",
284
+ border: "1px solid #ff006e",
285
+ shadow: "0 0 15px rgba(255, 0, 110, 0.6)"
286
+ },
287
+ success: {
288
+ emoji: "⚡",
289
+ label: "SUCCESS",
290
+ background: "linear-gradient(135deg, #003566 0%, #001d3d 100%)",
291
+ color: "#00f5ff",
292
+ border: "1px solid #00f5ff",
293
+ shadow: "0 0 15px rgba(0, 245, 255, 0.4)"
294
+ },
295
+ critical: {
296
+ emoji: "💥",
297
+ label: "CRITICAL",
298
+ background: "linear-gradient(135deg, #000000 0%, #ff0040 100%)",
299
+ color: "#ff0040",
300
+ border: "2px solid #ff0040",
301
+ shadow: "0 0 25px rgba(255, 0, 64, 0.8)"
302
+ }
303
+ }
304
+ };
305
+ const BANNER_VARIANTS = {
306
+ simple: {
307
+ text: "🚀 ADVANCED LOGGER v2.0.0 - State-of-the-art Console Styling 🚀",
308
+ style: "background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 20px; border-radius: 8px; font-weight: bold; font-size: 14px;"
309
+ },
310
+ ascii: {
311
+ text: `
312
+ ___ ____ _ __ ___ _ __ _____ _____ ____ __ ___ _____ _____ _____ ____
313
+ / _ \\ / __ \\| | / / / _ \\ | \\ | |/ ____| ____| _ \\ | | / _ \\ / ____| ___| _ | _ \\
314
+ / /_\\ \\ / / _\` | |/ / / /_\\ \\ | \\| | | | |__ | | | | | | / / \\ \\| | __| |_ | |_| | |_) |
315
+ | _ || | (_| | < | _ | | . \` | | | __| | | | | | | | | | | | |_ | _| | /| _ <
316
+ | | | |\\ \\__,_|_|\\_\\ | | | | | |\\ | |___| |____| |_| | | |__\\ \\_/ /| |__| | |___| |\\ \\| |_) |
317
+ \\_| |_/ \\____/ \\_| |_/ |_| \\_|\\_____|______|____/ |_____/\\___/ \\_____|_____|_| \\_|____/
318
+
319
+ Advanced Logger v2.0.0 - Console Excellence`,
320
+ style: 'font-family: "Courier New", Consolas, Monaco, monospace; color: #667eea; font-size: 11px; line-height: 1.2;'
321
+ },
322
+ unicode: {
323
+ text: `
324
+ ╔══════════════════════════════════════════════════════════════════════════╗
325
+ ║ 🚀 ADVANCED LOGGER v2.0.0 ║
326
+ ║ State-of-the-art Console Styling ║
327
+ ╚══════════════════════════════════════════════════════════════════════════╝`,
328
+ style: 'font-family: "Courier New", Consolas, Monaco, monospace; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 15px; border-radius: 8px; font-size: 12px; line-height: 1.3;'
329
+ },
330
+ svg: {
331
+ text: " ",
332
+ style: `
333
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 80'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='0%'><stop offset='0%' style='stop-color:%23667eea'/><stop offset='100%' style='stop-color:%23764ba2'/></linearGradient></defs><rect width='100%' height='100%' fill='url(%23grad)' rx='8'/><text x='200' y='30' text-anchor='middle' fill='white' font-family='monospace' font-size='14' font-weight='bold'>🚀 ADVANCED LOGGER</text><text x='200' y='50' text-anchor='middle' fill='white' font-family='monospace' font-size='12'>State-of-the-art Console Styling</text><text x='200' y='65' text-anchor='middle' fill='white' font-family='monospace' font-size='10'>v2.0.0</text></svg>");
334
+ background-repeat: no-repeat;
335
+ background-size: 400px 80px;
336
+ padding: 40px 200px;
337
+ color: transparent;
338
+ display: inline-block;
339
+ border-radius: 8px;
340
+ `
341
+ },
342
+ animated: {
343
+ text: " 🚀 ADVANCED LOGGER v2.0.0 ",
344
+ style: `
345
+ background: linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2);
346
+ background-size: 400% 400%;
347
+ color: white;
348
+ padding: 15px 25px;
349
+ border-radius: 10px;
350
+ font-weight: bold;
351
+ font-size: 14px;
352
+ font-family: monospace;
353
+ animation: gradientShift 3s ease infinite;
354
+ display: inline-block;
355
+ `
356
+ }
357
+ };
358
+ const THEME_BANNERS = {
359
+ default: {
360
+ simple: "🚀 ADVANCED LOGGER v2.0.0 - State-of-the-art Console Styling 🚀",
361
+ style: "background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 20px; border-radius: 8px; font-weight: bold;"
362
+ },
363
+ dark: {
364
+ simple: "🌙 ADVANCED LOGGER v2.0.0 - Dark Mode Console Excellence 🌙",
365
+ style: "background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%); color: #e2e8f0; padding: 12px 20px; border-radius: 8px; font-weight: bold; border: 1px solid #4a5568;"
366
+ },
367
+ neon: {
368
+ simple: "⚡ ADVANCED LOGGER v2.0.0 - Cyberpunk Console Experience ⚡",
369
+ style: "background: linear-gradient(135deg, #0f3460 0%, #e94560 100%); color: #00ffff; padding: 12px 20px; border-radius: 8px; font-weight: bold; text-shadow: 0 0 10px #00ffff;"
370
+ },
371
+ minimal: {
372
+ simple: "ADVANCED LOGGER v2.0.0 - Clean Console Styling",
373
+ style: "background: #f7fafc; color: #2d3748; padding: 8px 16px; border: 1px solid #e2e8f0; border-radius: 4px; font-weight: 500;"
374
+ },
375
+ light: {
376
+ simple: "☀️ ADVANCED LOGGER v2.0.0 - Bright Console Styling ☀️",
377
+ style: "background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); color: #495057; padding: 12px 20px; border-radius: 8px; font-weight: bold; border: 1px solid #dee2e6;"
378
+ },
379
+ cyberpunk: {
380
+ simple: "🤖 ADVANCED LOGGER v2.0.0 - Neural Console Interface 🤖",
381
+ style: "background: linear-gradient(135deg, #0d1b2a 0%, #415a77 100%); color: #00d4aa; padding: 12px 20px; border-radius: 8px; font-weight: bold; text-shadow: 0 0 10px #00d4aa; border: 1px solid #00d4aa;"
382
+ }
383
+ };
384
+ function detectBannerCapabilities() {
385
+ const userAgent = navigator.userAgent;
386
+ const isChrome = /Chrome/.test(userAgent);
387
+ const isFirefox = /Firefox/.test(userAgent);
388
+ const isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
389
+ const supportsSVG = !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect;
390
+ const supportsAnimations = typeof document !== "undefined" && "animationName" in document.createElement("div").style;
391
+ if (supportsAnimations && isChrome) {
392
+ return "animated";
393
+ } else if (supportsSVG && (isChrome || isFirefox)) {
394
+ return "svg";
395
+ } else if (isChrome || isFirefox) {
396
+ return "unicode";
397
+ } else if (isSafari) {
398
+ return "ascii";
399
+ }
400
+ return "simple";
401
+ }
402
+ function displayInitBanner(bannerType) {
403
+ const selectedType = bannerType || detectBannerCapabilities();
404
+ const banner = BANNER_VARIANTS[selectedType];
405
+ if (selectedType === "animated") {
406
+ const style = document.createElement("style");
407
+ style.textContent = `
408
+ @keyframes gradientShift {
409
+ 0% { background-position: 0% 50%; }
410
+ 50% { background-position: 100% 50%; }
411
+ 100% { background-position: 0% 50%; }
412
+ }
413
+ `;
414
+ document.head.appendChild(style);
415
+ }
416
+ console.log(`%c${banner.text}`, banner.style);
417
+ const features = [
418
+ "🎨 Advanced CSS Console Styling",
419
+ "📍 Automatic Stack Trace Parsing",
420
+ "🔧 Scoped Loggers & Prefixes",
421
+ "⚡ Performance Timers",
422
+ "🎯 Verbosity Filtering",
423
+ "🔌 Extensible Handlers",
424
+ "📱 Modern TypeScript Patterns",
425
+ "📤 Export & Clipboard Support"
426
+ ];
427
+ console.group(`%c✨ Features`, "background: #f8f9fa; color: #495057; padding: 4px 8px; border-radius: 4px; font-weight: bold;");
428
+ features.forEach((feature) => {
429
+ console.log(`%c${feature}`, "color: #6c757d; font-size: 13px;");
430
+ });
431
+ console.groupEnd();
432
+ console.log("");
433
+ }
434
+ function createStyledOutput(level, levelStyles, prefix, message, stackInfo) {
435
+ const levelConfig = levelStyles[level];
436
+ const timestamp = formatTimestamp();
437
+ const timestampStyle = new StyleBuilder().color("#666").size("11px").font("Monaco, Consolas, monospace").build();
438
+ const levelStyle = new StyleBuilder().bg(levelConfig.background).color(levelConfig.color).border(levelConfig.border).shadow(levelConfig.shadow).padding("2px 8px").rounded("4px").bold().font("Monaco, Consolas, monospace").size("12px").build();
439
+ const prefixStyle = new StyleBuilder().bg("#2d3748").color("#e2e8f0").padding("2px 6px").rounded("3px").bold().font("Monaco, Consolas, monospace").size("11px").build();
440
+ const messageStyle = new StyleBuilder().color("#2d3748").font("system-ui, -apple-system, sans-serif").size("14px").build();
441
+ const locationStyle = new StyleBuilder().color("#718096").size("11px").font("Monaco, Consolas, monospace").build();
442
+ let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
443
+ const styles = [timestampStyle, levelStyle];
444
+ if (prefix) {
445
+ format += ` %c${prefix}`;
446
+ styles.push(prefixStyle);
447
+ }
448
+ format += ` %c${message}`;
449
+ styles.push(messageStyle);
450
+ if (stackInfo) {
451
+ format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
452
+ styles.push(locationStyle);
453
+ }
454
+ return [format, ...styles];
455
+ }
456
+ function generateLogId() {
457
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
458
+ }
459
+ function escapeHtml(text) {
460
+ const div = document.createElement("div");
461
+ div.textContent = text;
462
+ return div.innerHTML;
463
+ }
464
+ function safeStringify(obj, _maxDepth = 3) {
465
+ try {
466
+ return JSON.stringify(obj, (_key, value) => {
467
+ if (typeof value === "function") return "[Function]";
468
+ if (value instanceof Error) return `[Error: ${value.message}]`;
469
+ if (value instanceof Date) return value.toISOString();
470
+ if (typeof value === "undefined") return "[undefined]";
471
+ return value;
472
+ }, 2);
473
+ } catch (error) {
474
+ return String(obj);
475
+ }
476
+ }
477
+ class ExportLogHandler {
478
+ buffer = [];
479
+ maxSize;
480
+ groupDepth = 0;
481
+ currentGroup;
482
+ constructor(maxSize = BUFFER_LIMITS.DEFAULT_SIZE) {
483
+ this.maxSize = Math.min(Math.max(maxSize, BUFFER_LIMITS.MIN_SIZE), BUFFER_LIMITS.MAX_SIZE);
484
+ }
485
+ /**
486
+ * Handle incoming log and store in buffer
487
+ */
488
+ handle(level, message, args, metadata) {
489
+ const entry = {
490
+ id: generateLogId(),
491
+ timestamp: metadata.timestamp,
492
+ level,
493
+ prefix: metadata.prefix,
494
+ message,
495
+ args,
496
+ location: metadata.stackInfo,
497
+ groupInfo: this.groupDepth > 0 ? {
498
+ depth: this.groupDepth,
499
+ groupName: this.currentGroup
500
+ } : void 0
501
+ };
502
+ this.buffer.push(entry);
503
+ if (this.buffer.length > this.maxSize) {
504
+ this.buffer.shift();
505
+ }
506
+ }
507
+ /**
508
+ * Set group tracking for nested logs
509
+ */
510
+ setGroupInfo(depth, groupName) {
511
+ this.groupDepth = depth;
512
+ this.currentGroup = groupName;
513
+ }
514
+ /**
515
+ * Get buffer statistics
516
+ */
517
+ getBufferStats() {
518
+ const levelCounts = this.buffer.reduce((acc, entry) => {
519
+ const currentCount = acc[entry.level] ? acc[entry.level] : 0;
520
+ acc[entry.level] = currentCount + 1;
521
+ return acc;
522
+ }, {});
523
+ let oldestLog;
524
+ let newestLog;
525
+ if (this.buffer.length > 0) {
526
+ const firstEntry = this.buffer[0];
527
+ const lastEntry = this.buffer[this.buffer.length - 1];
528
+ if (firstEntry && firstEntry.timestamp) {
529
+ oldestLog = new Date(firstEntry.timestamp);
530
+ }
531
+ if (lastEntry && lastEntry.timestamp) {
532
+ newestLog = new Date(lastEntry.timestamp);
533
+ }
534
+ }
535
+ return {
536
+ size: this.buffer.length,
537
+ maxSize: this.maxSize,
538
+ usage: this.buffer.length / this.maxSize * 100,
539
+ oldestLog,
540
+ newestLog,
541
+ levelCounts: {
542
+ debug: levelCounts.debug ? levelCounts.debug : 0,
543
+ info: levelCounts.info ? levelCounts.info : 0,
544
+ warn: levelCounts.warn ? levelCounts.warn : 0,
545
+ error: levelCounts.error ? levelCounts.error : 0,
546
+ critical: levelCounts.critical ? levelCounts.critical : 0
547
+ }
548
+ };
549
+ }
550
+ /**
551
+ * Clear the buffer
552
+ */
553
+ clearBuffer() {
554
+ this.buffer = [];
555
+ }
556
+ /**
557
+ * Set buffer size (with limits)
558
+ */
559
+ setBufferSize(size) {
560
+ this.maxSize = Math.min(Math.max(size, BUFFER_LIMITS.MIN_SIZE), BUFFER_LIMITS.MAX_SIZE);
561
+ if (this.buffer.length > this.maxSize) {
562
+ this.buffer = this.buffer.slice(-this.maxSize);
563
+ }
564
+ }
565
+ /**
566
+ * Filter logs based on criteria
567
+ */
568
+ filterLogs(filters = {}) {
569
+ let filtered = [...this.buffer];
570
+ if (filters.levels?.length) {
571
+ filtered = filtered.filter((entry) => filters.levels.includes(entry.level));
572
+ }
573
+ if (filters.prefixes?.length) {
574
+ filtered = filtered.filter(
575
+ (entry) => entry.prefix && filters.prefixes.includes(entry.prefix)
576
+ );
577
+ }
578
+ if (filters.excludePrefixes?.length) {
579
+ filtered = filtered.filter(
580
+ (entry) => !entry.prefix || !filters.excludePrefixes.includes(entry.prefix)
581
+ );
582
+ }
583
+ if (filters.since) {
584
+ const sinceDate = parseTimeInput(filters.since);
585
+ filtered = filtered.filter((entry) => new Date(entry.timestamp) >= sinceDate);
586
+ }
587
+ if (filters.until) {
588
+ const untilDate = parseTimeInput(filters.until);
589
+ filtered = filtered.filter((entry) => new Date(entry.timestamp) <= untilDate);
590
+ }
591
+ if (filters.withStackTrace) {
592
+ filtered = filtered.filter((entry) => entry.location);
593
+ }
594
+ if (filters.errorsOnly) {
595
+ filtered = filtered.filter((entry) => entry.level === "error" || entry.level === "critical");
596
+ }
597
+ if (filters.search) {
598
+ const searchTerm = filters.search.toLowerCase();
599
+ filtered = filtered.filter(
600
+ (entry) => entry.message.toLowerCase().includes(searchTerm) || entry.args.some(
601
+ (arg) => String(arg).toLowerCase().includes(searchTerm)
602
+ )
603
+ );
604
+ }
605
+ if (filters.last) {
606
+ filtered = filtered.slice(-filters.last);
607
+ }
608
+ if (filters.first) {
609
+ filtered = filtered.slice(0, filters.first);
610
+ }
611
+ return filtered;
612
+ }
613
+ /**
614
+ * Export logs in JSON format
615
+ */
616
+ exportJSON(logs, options) {
617
+ const data = logs.map((entry) => ({
618
+ timestamp: entry.timestamp,
619
+ level: entry.level,
620
+ prefix: entry.prefix,
621
+ message: entry.message,
622
+ ...options.minimal ? {} : {
623
+ args: entry.args.slice(1),
624
+ location: entry.location,
625
+ groupInfo: entry.groupInfo
626
+ }
627
+ }));
628
+ return options.compact ? JSON.stringify(data) : JSON.stringify(data, null, 2);
629
+ }
630
+ /**
631
+ * Export logs in CSV format
632
+ */
633
+ exportCSV(logs, options) {
634
+ const headers = options.minimal ? ["Timestamp", "Level", "Prefix", "Message"] : ["Timestamp", "Level", "Prefix", "Message", "File", "Line", "Args"];
635
+ const rows = logs.map((entry) => {
636
+ const baseRow = [
637
+ formatDisplayTime(new Date(entry.timestamp), "full"),
638
+ entry.level.toUpperCase(),
639
+ entry.prefix || "",
640
+ `"${entry.message.replace(/"/g, '""')}"`
641
+ ];
642
+ if (!options.minimal) {
643
+ baseRow.push(
644
+ entry.location?.file || "",
645
+ entry.location?.line?.toString() || "",
646
+ `"${safeStringify(entry.args.slice(1)).replace(/"/g, '""')}"`
647
+ );
648
+ }
649
+ return baseRow;
650
+ });
651
+ return [headers.join(","), ...rows.map((row) => row.join(","))].join("\n");
652
+ }
653
+ /**
654
+ * Export logs in Markdown format
655
+ */
656
+ exportMarkdown(logs, options) {
657
+ const now = /* @__PURE__ */ new Date();
658
+ let content = `# Log Export - ${formatDisplayTime(now, "full")}
659
+
660
+ `;
661
+ if (!options.minimal) {
662
+ const summary = this.getBufferStats();
663
+ content += `## Summary
664
+ `;
665
+ content += `- **Total logs**: ${logs.length}
666
+ `;
667
+ content += `- **Errors**: ${summary.levelCounts.error + summary.levelCounts.critical}
668
+ `;
669
+ content += `- **Warnings**: ${summary.levelCounts.warn}
670
+
671
+ `;
672
+ }
673
+ if (options.groupBy === "level") {
674
+ const grouped = logs.reduce((acc, entry) => {
675
+ const level = entry.level;
676
+ if (!acc[level]) {
677
+ acc[level] = [];
678
+ }
679
+ const levelArray = acc[level];
680
+ if (levelArray) {
681
+ levelArray.push(entry);
682
+ }
683
+ return acc;
684
+ }, {});
685
+ Object.entries(grouped).forEach(([level, entries]) => {
686
+ const emoji = this.getLevelEmoji(level);
687
+ content += `## ${emoji} ${level.toUpperCase()} (${entries.length})
688
+
689
+ `;
690
+ entries.forEach((entry) => {
691
+ const time = formatDisplayTime(new Date(entry.timestamp), "time-only");
692
+ const location = entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
693
+ const prefix = entry.prefix ? ` **${entry.prefix}**:` : "";
694
+ content += `- \`${time}\`${prefix} ${entry.message}${location}
695
+ `;
696
+ });
697
+ content += "\n";
698
+ });
699
+ } else {
700
+ content += "## Logs\n\n";
701
+ logs.forEach((entry) => {
702
+ const time = formatDisplayTime(new Date(entry.timestamp), "time-only");
703
+ const emoji = this.getLevelEmoji(entry.level);
704
+ const location = entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
705
+ const prefix = entry.prefix ? ` **${entry.prefix}**:` : "";
706
+ content += `- \`${time}\` ${emoji}${prefix} ${entry.message}${location}
707
+ `;
708
+ });
709
+ }
710
+ return content;
711
+ }
712
+ /**
713
+ * Export logs in plain text format
714
+ */
715
+ exportPlain(logs, options) {
716
+ return logs.map((entry) => {
717
+ const time = formatDisplayTime(new Date(entry.timestamp), options.minimal ? "time-only" : "short");
718
+ const level = entry.level.toUpperCase().padEnd(8);
719
+ const prefix = entry.prefix ? `[${entry.prefix}] ` : "";
720
+ const location = !options.minimal && entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
721
+ return `${time} ${level} ${prefix}${entry.message}${location}`;
722
+ }).join("\n");
723
+ }
724
+ /**
725
+ * Export logs in HTML format
726
+ */
727
+ exportHTML(logs, _options) {
728
+ const title = `Log Export - ${formatDisplayTime(/* @__PURE__ */ new Date(), "full")}`;
729
+ let html = `<!DOCTYPE html>
730
+ <html lang="en">
731
+ <head>
732
+ <meta charset="UTF-8">
733
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
734
+ <title>${title}</title>
735
+ <style>
736
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 20px; line-height: 1.6; }
737
+ .header { border-bottom: 2px solid #ddd; padding-bottom: 20px; margin-bottom: 20px; }
738
+ .log-entry { margin: 5px 0; padding: 8px; border-radius: 4px; font-family: 'Monaco', 'Consolas', monospace; }
739
+ .timestamp { color: #666; font-size: 0.9em; }
740
+ .level { font-weight: bold; padding: 2px 6px; border-radius: 3px; margin: 0 8px; }
741
+ .prefix { background: #2d3748; color: #e2e8f0; padding: 2px 6px; border-radius: 3px; margin: 0 8px; }
742
+ .location { color: #718096; font-size: 0.9em; }
743
+ .debug { background: #f0f4ff; }
744
+ .info { background: #f0f9ff; }
745
+ .warn { background: #fffbeb; }
746
+ .error { background: #fef2f2; }
747
+ .critical { background: #fef2f2; border-left: 4px solid #dc2626; }
748
+ .level.debug { background: #667eea; color: white; }
749
+ .level.info { background: #74b9ff; color: white; }
750
+ .level.warn { background: #fdcb6e; color: #2d3436; }
751
+ .level.error { background: #e84393; color: white; }
752
+ .level.critical { background: #ff3838; color: white; }
753
+ </style>
754
+ </head>
755
+ <body>
756
+ <div class="header">
757
+ <h1>${title}</h1>
758
+ <p>Generated by Advanced Logger v2.0.0</p>
759
+ </div>
760
+ <div class="logs">`;
761
+ logs.forEach((entry) => {
762
+ const time = formatDisplayTime(new Date(entry.timestamp), "full");
763
+ const location = entry.location ? ` <span class="location">(${escapeHtml(entry.location.file)}:${entry.location.line})</span>` : "";
764
+ const prefix = entry.prefix ? ` <span class="prefix">${escapeHtml(entry.prefix)}</span>` : "";
765
+ html += `
766
+ <div class="log-entry ${entry.level}">
767
+ <span class="timestamp">${time}</span>
768
+ <span class="level ${entry.level}">${entry.level.toUpperCase()}</span>
769
+ ${prefix}
770
+ <span class="message">${escapeHtml(entry.message)}</span>
771
+ ${location}
772
+ </div>`;
773
+ });
774
+ html += `
775
+ </div>
776
+ </body>
777
+ </html>`;
778
+ return html;
779
+ }
780
+ /**
781
+ * Get emoji for log level
782
+ */
783
+ getLevelEmoji(level) {
784
+ const emojis = {
785
+ debug: "🐞",
786
+ info: "ℹ️",
787
+ warn: "⚠️",
788
+ error: "❌",
789
+ critical: "🔥"
790
+ };
791
+ return emojis[level] || "";
792
+ }
793
+ /**
794
+ * Main export function
795
+ */
796
+ export(format, filters = {}, options = {}) {
797
+ const filteredLogs = this.filterLogs(filters);
798
+ let data;
799
+ switch (format) {
800
+ case "json":
801
+ data = this.exportJSON(filteredLogs, options);
802
+ break;
803
+ case "csv":
804
+ data = this.exportCSV(filteredLogs, options);
805
+ break;
806
+ case "markdown":
807
+ data = this.exportMarkdown(filteredLogs, options);
808
+ break;
809
+ case "plain":
810
+ data = this.exportPlain(filteredLogs, options);
811
+ break;
812
+ case "html":
813
+ data = this.exportHTML(filteredLogs, options);
814
+ break;
815
+ default:
816
+ throw new Error(`Unsupported export format: ${format}`);
817
+ }
818
+ return {
819
+ format,
820
+ data,
821
+ metadata: {
822
+ totalLogs: this.buffer.length,
823
+ filteredLogs: filteredLogs.length,
824
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
825
+ filters,
826
+ options
827
+ }
828
+ };
829
+ }
830
+ /**
831
+ * Copy to clipboard with fallback
832
+ */
833
+ async copyToClipboard(format, filters = {}, options = {}) {
834
+ const result = this.export(format, filters, options);
835
+ try {
836
+ if (navigator.clipboard && window.isSecureContext) {
837
+ await navigator.clipboard.writeText(result.data);
838
+ return true;
839
+ } else {
840
+ const textArea = document.createElement("textarea");
841
+ textArea.value = result.data;
842
+ textArea.style.position = "fixed";
843
+ textArea.style.opacity = "0";
844
+ document.body.appendChild(textArea);
845
+ textArea.focus();
846
+ textArea.select();
847
+ const success = document.execCommand("copy");
848
+ document.body.removeChild(textArea);
849
+ return success;
850
+ }
851
+ } catch (error) {
852
+ console.error("Failed to copy to clipboard:", error);
853
+ return false;
854
+ }
855
+ }
856
+ /**
857
+ * Get all logs (for debugging)
858
+ */
859
+ getAllLogs() {
860
+ return [...this.buffer];
861
+ }
862
+ /**
863
+ * Save export to file with download prompt
864
+ */
865
+ async saveToFile(format, filters = {}, options = {}) {
866
+ try {
867
+ const result = this.export(format, filters, options);
868
+ const blob = new Blob([result.data], {
869
+ type: this.getMimeType(format)
870
+ });
871
+ const url = URL.createObjectURL(blob);
872
+ const a = document.createElement("a");
873
+ const filename = this.generateFilename(format, filters);
874
+ a.href = url;
875
+ a.download = filename;
876
+ a.style.display = "none";
877
+ document.body.appendChild(a);
878
+ a.click();
879
+ document.body.removeChild(a);
880
+ URL.revokeObjectURL(url);
881
+ return true;
882
+ } catch (error) {
883
+ console.error("Failed to save file:", error);
884
+ return false;
885
+ }
886
+ }
887
+ /**
888
+ * Get MIME type for format
889
+ */
890
+ getMimeType(format) {
891
+ const mimeTypes = {
892
+ json: "application/json",
893
+ csv: "text/csv",
894
+ markdown: "text/markdown",
895
+ plain: "text/plain",
896
+ html: "text/html"
897
+ };
898
+ return mimeTypes[format] || "text/plain";
899
+ }
900
+ /**
901
+ * Generate filename with timestamp
902
+ */
903
+ generateFilename(format, filters) {
904
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
905
+ const prefix = filters.prefixes?.length === 1 ? `_${filters.prefixes[0]}` : "";
906
+ const extension = format === "markdown" ? "md" : format;
907
+ return `logs${prefix}_${timestamp}.${extension}`;
908
+ }
909
+ /**
910
+ * Stream logs to external endpoint
911
+ */
912
+ async streamToEndpoint(endpoint, filters = {}, options = {}) {
913
+ try {
914
+ const logs = this.filterLogs(filters);
915
+ const batchSize = options.batchSize || 100;
916
+ const format = options.format || "json";
917
+ for (let i = 0; i < logs.length; i += batchSize) {
918
+ const batch = logs.slice(i, i + batchSize);
919
+ const result = this.export(format, {}, { compact: true });
920
+ const headers = {
921
+ "Content-Type": "application/json"
922
+ };
923
+ if (options.apiKey) {
924
+ headers["Authorization"] = `Bearer ${options.apiKey}`;
925
+ }
926
+ const response = await fetch(endpoint, {
927
+ method: "POST",
928
+ headers,
929
+ body: JSON.stringify({
930
+ logs: batch,
931
+ metadata: {
932
+ batchIndex: Math.floor(i / batchSize),
933
+ totalBatches: Math.ceil(logs.length / batchSize),
934
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
935
+ }
936
+ })
937
+ });
938
+ if (!response.ok) {
939
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
940
+ }
941
+ }
942
+ return true;
943
+ } catch (error) {
944
+ console.error("Failed to stream logs:", error);
945
+ return false;
946
+ }
947
+ }
948
+ /**
949
+ * Create export with metadata enrichment
950
+ */
951
+ exportWithMetadata(format, filters = {}, options = {}) {
952
+ const baseResult = this.export(format, filters, options);
953
+ const bufferStats = this.getBufferStats();
954
+ return {
955
+ ...baseResult,
956
+ metadata: {
957
+ ...baseResult.metadata,
958
+ bufferStats,
959
+ performance: {
960
+ memoryUsage: this.estimateMemoryUsage(),
961
+ processingTime: Date.now()
962
+ },
963
+ system: {
964
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Node.js",
965
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
966
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
967
+ }
968
+ }
969
+ };
970
+ }
971
+ /**
972
+ * Estimate memory usage of buffer
973
+ */
974
+ estimateMemoryUsage() {
975
+ const sampleEntry = this.buffer[0];
976
+ if (!sampleEntry) return 0;
977
+ const sampleSize = JSON.stringify(sampleEntry).length;
978
+ return sampleSize * this.buffer.length;
979
+ }
980
+ }
981
+ class CommandProcessor {
982
+ commands = /* @__PURE__ */ new Map();
983
+ aliases = /* @__PURE__ */ new Map();
984
+ plugins = /* @__PURE__ */ new Map();
985
+ history = [];
986
+ maxHistorySize = 100;
987
+ isInteractiveMode = false;
988
+ /**
989
+ * Register a command
990
+ */
991
+ registerCommand(command) {
992
+ this.commands.set(command.name, command);
993
+ if (command.aliases) {
994
+ for (const alias of command.aliases) {
995
+ this.aliases.set(alias, command.name);
996
+ }
997
+ }
998
+ }
999
+ /**
1000
+ * Register a plugin
1001
+ */
1002
+ registerPlugin(plugin, logger) {
1003
+ if (this.plugins.has(plugin.name)) {
1004
+ throw new Error(`Plugin ${plugin.name} is already registered`);
1005
+ }
1006
+ this.plugins.set(plugin.name, plugin);
1007
+ for (const command of plugin.commands) {
1008
+ this.registerCommand(command);
1009
+ }
1010
+ if (plugin.initialize && logger) {
1011
+ plugin.initialize(this, logger);
1012
+ }
1013
+ }
1014
+ /**
1015
+ * Unregister a plugin
1016
+ */
1017
+ unregisterPlugin(pluginName) {
1018
+ const plugin = this.plugins.get(pluginName);
1019
+ if (!plugin) return;
1020
+ for (const command of plugin.commands) {
1021
+ this.commands.delete(command.name);
1022
+ if (command.aliases) {
1023
+ for (const alias of command.aliases) {
1024
+ this.aliases.delete(alias);
1025
+ }
1026
+ }
1027
+ }
1028
+ if (plugin.cleanup) {
1029
+ plugin.cleanup();
1030
+ }
1031
+ this.plugins.delete(pluginName);
1032
+ }
1033
+ /**
1034
+ * Get all registered commands
1035
+ */
1036
+ getCommands() {
1037
+ return Array.from(this.commands.values());
1038
+ }
1039
+ /**
1040
+ * Get a specific command
1041
+ */
1042
+ getCommand(name) {
1043
+ let command = this.commands.get(name);
1044
+ if (command) return command;
1045
+ const aliasTarget = this.aliases.get(name);
1046
+ if (aliasTarget) {
1047
+ return this.commands.get(aliasTarget);
1048
+ }
1049
+ return void 0;
1050
+ }
1051
+ /**
1052
+ * Get command history
1053
+ */
1054
+ getHistory() {
1055
+ return [...this.history];
1056
+ }
1057
+ /**
1058
+ * Clear command history
1059
+ */
1060
+ clearHistory() {
1061
+ this.history = [];
1062
+ }
1063
+ /**
1064
+ * Get registered plugins
1065
+ */
1066
+ getPlugins() {
1067
+ return Array.from(this.plugins.values());
1068
+ }
1069
+ /**
1070
+ * Enter interactive mode
1071
+ */
1072
+ enterInteractiveMode(logger) {
1073
+ this.isInteractiveMode = true;
1074
+ logger.info("🔧 Interactive CLI mode activated. Type /exit to quit, /help for commands.");
1075
+ if (typeof window !== "undefined") {
1076
+ this.setupBrowserInteractiveMode(logger);
1077
+ }
1078
+ }
1079
+ /**
1080
+ * Exit interactive mode
1081
+ */
1082
+ exitInteractiveMode() {
1083
+ this.isInteractiveMode = false;
1084
+ }
1085
+ /**
1086
+ * Setup browser interactive mode
1087
+ */
1088
+ setupBrowserInteractiveMode(logger) {
1089
+ window.cli = (commandString) => {
1090
+ return this.processCommand(`/${commandString}`, logger);
1091
+ };
1092
+ logger.info('💡 Use cli("command") to execute CLI commands in browser console.');
1093
+ }
1094
+ /**
1095
+ * Process a CLI command
1096
+ */
1097
+ async processCommand(commandString, logger) {
1098
+ if (!commandString.startsWith("/")) {
1099
+ logger.error("Invalid command. Commands must start with /");
1100
+ this.addToHistory(commandString, false);
1101
+ return;
1102
+ }
1103
+ const parts = commandString.slice(1).split(" ");
1104
+ const commandName = parts[0] || "";
1105
+ const args = parts.slice(1).join(" ");
1106
+ const command = this.getCommand(commandName);
1107
+ if (!command) {
1108
+ logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
1109
+ const suggestions = this.getSuggestions(commandName);
1110
+ if (suggestions.length > 0) {
1111
+ logger.info(`📋 Did you mean: ${suggestions.slice(0, 3).join(", ")}?`);
1112
+ }
1113
+ this.addToHistory(commandString, false);
1114
+ return;
1115
+ }
1116
+ try {
1117
+ await command.execute(args || "", logger);
1118
+ this.addToHistory(commandString, true);
1119
+ } catch (error) {
1120
+ logger.error(`Command '${commandName}' failed:`, error);
1121
+ this.addToHistory(commandString, false);
1122
+ }
1123
+ }
1124
+ /**
1125
+ * Add command to history
1126
+ */
1127
+ addToHistory(command, success) {
1128
+ this.history.unshift({
1129
+ command,
1130
+ timestamp: /* @__PURE__ */ new Date(),
1131
+ success
1132
+ });
1133
+ if (this.history.length > this.maxHistorySize) {
1134
+ this.history = this.history.slice(0, this.maxHistorySize);
1135
+ }
1136
+ }
1137
+ /**
1138
+ * Get command suggestions for partial matches
1139
+ */
1140
+ getSuggestions(partial) {
1141
+ const commandNames = Array.from(this.commands.keys());
1142
+ return commandNames.filter((name) => name.startsWith(partial));
1143
+ }
1144
+ }
1145
+ class ConfigCommand {
1146
+ name = "config";
1147
+ description = "Show or update logger configuration";
1148
+ usage = "/config [json|key=value,...]";
1149
+ execute(args, logger) {
1150
+ if (!args) {
1151
+ this.showStatus(logger);
1152
+ return;
1153
+ }
1154
+ try {
1155
+ if (args.startsWith("{")) {
1156
+ const config = JSON.parse(args);
1157
+ this.applyConfig(config, logger);
1158
+ } else {
1159
+ const pairs = args.split(",").map((pair) => pair.trim().split("="));
1160
+ const config = {};
1161
+ pairs.forEach(([key, value]) => {
1162
+ if (key && value) {
1163
+ config[key.trim()] = value.trim().replace(/["']/g, "");
1164
+ }
1165
+ });
1166
+ this.applyConfig(config, logger);
1167
+ }
1168
+ } catch (error) {
1169
+ logger.error("Invalid config format. Use JSON or key=value pairs:", error);
1170
+ logger.info('Examples: /config {"theme":"dark"} or /config theme=neon,verbosity=debug');
1171
+ }
1172
+ }
1173
+ showStatus(logger) {
1174
+ const statusData = {
1175
+ theme: logger.getConfig().theme || "default",
1176
+ verbosity: logger.getConfig().verbosity,
1177
+ colors: logger.getConfig().enableColors,
1178
+ timestamps: logger.getConfig().enableTimestamps,
1179
+ stackTrace: logger.getConfig().enableStackTrace,
1180
+ globalPrefix: logger.getConfig().globalPrefix || "none",
1181
+ bannerType: logger.getConfig().bannerType || "simple",
1182
+ handlers: logger.getHandlers().length
1183
+ };
1184
+ logger.group("⚙️ Logger Configuration");
1185
+ logger.table(statusData);
1186
+ logger.groupEnd();
1187
+ }
1188
+ applyConfig(config, logger) {
1189
+ const validKeys = ["theme", "verbosity", "enableColors", "enableTimestamps", "enableStackTrace", "globalPrefix", "bannerType"];
1190
+ const applied = [];
1191
+ Object.entries(config).forEach(([key, value]) => {
1192
+ if (validKeys.includes(key)) {
1193
+ if (key === "theme" && typeof value === "string") {
1194
+ logger.setTheme(value);
1195
+ applied.push(`${key}=${value}`);
1196
+ } else if (key === "bannerType" && typeof value === "string") {
1197
+ logger.setBannerType(value);
1198
+ applied.push(`${key}=${value}`);
1199
+ } else if (key === "verbosity") {
1200
+ logger.setVerbosity(value);
1201
+ applied.push(`${key}=${value}`);
1202
+ } else if (key === "globalPrefix") {
1203
+ logger.setGlobalPrefix(value);
1204
+ applied.push(`${key}=${value}`);
1205
+ } else {
1206
+ logger.updateConfig({ [key]: value });
1207
+ applied.push(`${key}=${value}`);
1208
+ }
1209
+ } else {
1210
+ logger.warn(`Invalid config key: ${key}`);
1211
+ }
1212
+ });
1213
+ if (applied.length > 0) {
1214
+ logger.success(`Configuration updated: ${applied.join(", ")}`);
1215
+ }
1216
+ }
1217
+ }
1218
+ class ThemesCommand {
1219
+ name = "themes";
1220
+ description = "Show available theme presets";
1221
+ usage = "/themes";
1222
+ execute(_args, logger) {
1223
+ logger.group("🎨 Available Themes");
1224
+ Object.keys(THEME_PRESETS).forEach((themeName) => {
1225
+ const preview = THEME_PRESETS[themeName];
1226
+ const previewStyle = new StyleBuilder().bg(preview.info.background).color(preview.info.color).padding("4px 8px").rounded("4px").border(preview.info.border).build();
1227
+ console.log(`%c${themeName}`, previewStyle, `- ${themeName} theme preview`);
1228
+ });
1229
+ logger.groupEnd();
1230
+ }
1231
+ }
1232
+ class BannersCommand {
1233
+ name = "banners";
1234
+ description = "Show available banner types";
1235
+ usage = "/banners";
1236
+ execute(_args, logger) {
1237
+ logger.group("🖼️ Available Banner Types");
1238
+ Object.keys(BANNER_VARIANTS).forEach((bannerName) => {
1239
+ const banner = BANNER_VARIANTS[bannerName];
1240
+ console.log(`%c${bannerName}`, "font-weight: bold; color: #667eea;");
1241
+ console.log(`%cPreview:`, "color: #666; font-size: 12px;");
1242
+ if (bannerName === "simple") {
1243
+ console.log(`%c${banner.text}`, banner.style);
1244
+ } else if (bannerName === "ascii") {
1245
+ console.log(`%c${banner.text.split("\n").slice(1, 4).join("\n")}...`, "font-family: monospace; color: #667eea; font-size: 10px;");
1246
+ } else if (bannerName === "unicode") {
1247
+ console.log(`%c${banner.text}`, banner.style);
1248
+ } else {
1249
+ console.log(`%c${bannerName} banner`, "color: #666; font-style: italic;");
1250
+ }
1251
+ });
1252
+ logger.groupEnd();
1253
+ }
1254
+ }
1255
+ class BannerCommand {
1256
+ name = "banner";
1257
+ description = "Change or show current banner type";
1258
+ usage = "/banner [type]";
1259
+ execute(args, logger) {
1260
+ if (!args) {
1261
+ logger.showBanner();
1262
+ return;
1263
+ }
1264
+ if (args in BANNER_VARIANTS) {
1265
+ logger.setBannerType(args);
1266
+ logger.showBanner();
1267
+ } else {
1268
+ logger.error(`Invalid banner type: ${args}. Available: ${Object.keys(BANNER_VARIANTS).join(", ")}`);
1269
+ }
1270
+ }
1271
+ }
1272
+ class StatusCommand {
1273
+ name = "status";
1274
+ description = "Show current logger status and configuration";
1275
+ usage = "/status";
1276
+ execute(_args, logger) {
1277
+ const config = logger.getConfig();
1278
+ const statusData = {
1279
+ theme: config.theme ? config.theme : "default",
1280
+ verbosity: config.verbosity,
1281
+ colors: config.enableColors,
1282
+ timestamps: config.enableTimestamps,
1283
+ stackTrace: config.enableStackTrace,
1284
+ globalPrefix: config.globalPrefix ? config.globalPrefix : "none",
1285
+ bannerType: config.bannerType ? config.bannerType : "simple",
1286
+ handlers: logger.getHandlers().length,
1287
+ bufferSize: config.bufferSize ? config.bufferSize : 1e3
1288
+ };
1289
+ logger.group("⚙️ Logger Configuration");
1290
+ logger.table(statusData);
1291
+ logger.groupEnd();
1292
+ const exportHandler = logger.getExportHandler();
1293
+ if (exportHandler) {
1294
+ const bufferStats = exportHandler.getBufferStats();
1295
+ logger.group("📊 Buffer Statistics");
1296
+ logger.table({
1297
+ size: `${bufferStats.size}/${bufferStats.maxSize}`,
1298
+ usage: `${bufferStats.usage.toFixed(1)}%`,
1299
+ oldestLog: bufferStats.oldestLog ? bufferStats.oldestLog.toISOString() : "None",
1300
+ newestLog: bufferStats.newestLog ? bufferStats.newestLog.toISOString() : "None",
1301
+ errorCount: bufferStats.levelCounts.error + bufferStats.levelCounts.critical,
1302
+ warningCount: bufferStats.levelCounts.warn
1303
+ });
1304
+ logger.groupEnd();
1305
+ }
1306
+ }
1307
+ }
1308
+ class ResetCommand {
1309
+ name = "reset";
1310
+ description = "Reset logger configuration to defaults";
1311
+ usage = "/reset";
1312
+ execute(_args, logger) {
1313
+ logger.resetConfig();
1314
+ }
1315
+ }
1316
+ class DemoCommand {
1317
+ name = "demo";
1318
+ description = "Show comprehensive feature demonstration";
1319
+ usage = "/demo";
1320
+ execute(_args, logger) {
1321
+ logger.group("🎪 Advanced Logger Demo");
1322
+ logger.debug("Debug message with detailed information");
1323
+ logger.info("Informational message about system state");
1324
+ logger.warn("Warning about deprecated feature");
1325
+ logger.error("Error processing user request");
1326
+ logger.success("Operation completed successfully");
1327
+ logger.critical("Critical system failure detected");
1328
+ logger.group("📊 Advanced Features Demo");
1329
+ logger.table([
1330
+ { feature: "Styled Console", status: "✅ Active", performance: "Excellent" },
1331
+ { feature: "Theme System", status: "✅ Active", performance: "Great" },
1332
+ { feature: "CLI Interface", status: "✅ Active", performance: "Good" },
1333
+ { feature: "Export System", status: "✅ Active", performance: "Excellent" }
1334
+ ]);
1335
+ logger.time("demo-operation");
1336
+ setTimeout(() => {
1337
+ logger.timeEnd("demo-operation");
1338
+ }, 100);
1339
+ logger.logWithSVG("SVG Demo");
1340
+ logger.logAnimated("🌟 Animated Logger Demo 🌟", 2);
1341
+ logger.groupEnd();
1342
+ logger.groupEnd();
1343
+ logger.info("Demo completed! Check the console for styled output.");
1344
+ }
1345
+ }
1346
+ function parseArguments(args) {
1347
+ const filters = {};
1348
+ const options = {};
1349
+ let format;
1350
+ if (!args.trim()) return { filters, options };
1351
+ const argParts = args.match(/(?:[^\s"]+|"[^"]*")+/g) || [];
1352
+ for (let i = 0; i < argParts.length; i++) {
1353
+ const arg = argParts[i];
1354
+ if (!arg) {
1355
+ continue;
1356
+ }
1357
+ if (i === 0 && !arg.startsWith("--") && arg in EXPORT_FORMATS) {
1358
+ format = arg;
1359
+ continue;
1360
+ }
1361
+ if (arg.startsWith("--")) {
1362
+ const [flag, value] = arg.slice(2).split("=");
1363
+ switch (flag) {
1364
+ case "level":
1365
+ case "levels":
1366
+ if (value) {
1367
+ filters.levels = value.split(",").map((l) => l.trim());
1368
+ }
1369
+ break;
1370
+ case "since":
1371
+ if (value) filters.since = value;
1372
+ break;
1373
+ case "until":
1374
+ if (value) filters.until = value;
1375
+ break;
1376
+ case "prefix":
1377
+ case "prefixes":
1378
+ if (value) {
1379
+ filters.prefixes = value.split(",").map((p) => p.trim());
1380
+ }
1381
+ break;
1382
+ case "exclude-prefix":
1383
+ case "exclude-prefixes":
1384
+ if (value) {
1385
+ filters.excludePrefixes = value.split(",").map((p) => p.trim());
1386
+ }
1387
+ break;
1388
+ case "last":
1389
+ if (value) filters.last = parseInt(value, 10);
1390
+ break;
1391
+ case "first":
1392
+ if (value) filters.first = parseInt(value, 10);
1393
+ break;
1394
+ case "search":
1395
+ if (value) filters.search = value.replace(/['"]/g, "");
1396
+ break;
1397
+ case "with-stack":
1398
+ filters.withStackTrace = true;
1399
+ break;
1400
+ case "errors-only":
1401
+ filters.errorsOnly = true;
1402
+ break;
1403
+ case "group-by":
1404
+ if (value) {
1405
+ filters.groupBy = value;
1406
+ options.groupBy = value;
1407
+ }
1408
+ break;
1409
+ case "minimal":
1410
+ options.minimal = true;
1411
+ break;
1412
+ case "compact":
1413
+ options.compact = true;
1414
+ break;
1415
+ case "styled":
1416
+ options.styled = true;
1417
+ break;
1418
+ }
1419
+ }
1420
+ }
1421
+ return { filters, options, format };
1422
+ }
1423
+ class ExportCommand {
1424
+ name = "export";
1425
+ description = "Export logs to various formats";
1426
+ usage = "/export <format> [--filter=value] [--option]";
1427
+ execute(args, logger) {
1428
+ const exportHandler = logger.getExportHandler();
1429
+ if (!exportHandler) {
1430
+ logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
1431
+ return;
1432
+ }
1433
+ const { filters, options, format } = parseArguments(args);
1434
+ if (!format) {
1435
+ logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
1436
+ logger.info("Usage: /export <format> [--filter=value]");
1437
+ logger.info("Example: /export json --level=error,warn --last=50");
1438
+ return;
1439
+ }
1440
+ try {
1441
+ const result = exportHandler.export(format, filters, options);
1442
+ logger.success(`✅ Export completed: ${result.metadata.filteredLogs} logs exported in ${format} format`);
1443
+ if (result.data.length < 1e3) {
1444
+ logger.group(`📄 Preview (${format.toUpperCase()})`);
1445
+ console.log(result.data);
1446
+ logger.groupEnd();
1447
+ } else {
1448
+ logger.info(`📄 Export size: ${(result.data.length / 1024).toFixed(2)}KB`);
1449
+ }
1450
+ logger.table({
1451
+ format: result.format,
1452
+ totalLogs: result.metadata.totalLogs,
1453
+ filtered: result.metadata.filteredLogs,
1454
+ exported: result.metadata.exportedAt
1455
+ });
1456
+ } catch (error) {
1457
+ logger.error("Export failed:", error);
1458
+ }
1459
+ }
1460
+ }
1461
+ class CopyCommand {
1462
+ name = "copy";
1463
+ description = "Copy logs to clipboard";
1464
+ usage = "/copy <format> [--filter=value] [--option]";
1465
+ async execute(args, logger) {
1466
+ const exportHandler = logger.getExportHandler();
1467
+ if (!exportHandler) {
1468
+ logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
1469
+ return;
1470
+ }
1471
+ const { filters, options, format } = parseArguments(args);
1472
+ if (!format) {
1473
+ logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
1474
+ logger.info("Usage: /copy <format> [--filter=value]");
1475
+ logger.info("Example: /copy plain --level=error --last=25");
1476
+ return;
1477
+ }
1478
+ try {
1479
+ const success = await exportHandler.copyToClipboard(format, filters, options);
1480
+ if (success) {
1481
+ const result = exportHandler.export(format, filters, options);
1482
+ logger.success(`📋 Copied ${result.metadata.filteredLogs} logs to clipboard (${format} format)`);
1483
+ } else {
1484
+ logger.error("Failed to copy to clipboard. Browser may not support clipboard API.");
1485
+ }
1486
+ } catch (error) {
1487
+ logger.error("Copy failed:", error);
1488
+ }
1489
+ }
1490
+ }
1491
+ class BufferSizeCommand {
1492
+ name = "buffer-size";
1493
+ description = "Set log buffer size";
1494
+ usage = "/buffer-size <size>";
1495
+ execute(args, logger) {
1496
+ const exportHandler = logger.getExportHandler();
1497
+ if (!exportHandler) {
1498
+ logger.error("Export handler not available.");
1499
+ return;
1500
+ }
1501
+ const size = parseInt(args.trim(), 10);
1502
+ if (isNaN(size) || size <= 0) {
1503
+ logger.error("Invalid buffer size. Must be a positive number.");
1504
+ logger.info("Example: /buffer-size 2000");
1505
+ return;
1506
+ }
1507
+ exportHandler.setBufferSize(size);
1508
+ logger.success(`Buffer size set to ${size}`);
1509
+ }
1510
+ }
1511
+ class ClearBufferCommand {
1512
+ name = "clear-buffer";
1513
+ description = "Clear the log buffer";
1514
+ usage = "/clear-buffer";
1515
+ execute(_args, logger) {
1516
+ const exportHandler = logger.getExportHandler();
1517
+ if (!exportHandler) {
1518
+ logger.error("Export handler not available.");
1519
+ return;
1520
+ }
1521
+ const stats = exportHandler.getBufferStats();
1522
+ exportHandler.clearBuffer();
1523
+ logger.success(`✅ Buffer cleared. Removed ${stats.size} log entries.`);
1524
+ }
1525
+ }
1526
+ class BufferInfoCommand {
1527
+ name = "buffer-info";
1528
+ description = "Show buffer statistics and information";
1529
+ usage = "/buffer-info";
1530
+ execute(_args, logger) {
1531
+ const exportHandler = logger.getExportHandler();
1532
+ if (!exportHandler) {
1533
+ logger.error("Export handler not available.");
1534
+ return;
1535
+ }
1536
+ const stats = exportHandler.getBufferStats();
1537
+ logger.group("📊 Buffer Information");
1538
+ logger.table({
1539
+ size: `${stats.size}/${stats.maxSize}`,
1540
+ usage: `${stats.usage.toFixed(1)}%`,
1541
+ oldestLog: stats.oldestLog?.toLocaleString() || "None",
1542
+ newestLog: stats.newestLog?.toLocaleString() || "None"
1543
+ });
1544
+ logger.group("📈 Log Level Counts");
1545
+ logger.table(stats.levelCounts);
1546
+ logger.groupEnd();
1547
+ logger.groupEnd();
1548
+ }
1549
+ }
1550
+ class HelpCommand {
1551
+ name = "help";
1552
+ description = "Show CLI help and available commands";
1553
+ usage = "/help [command]";
1554
+ execute(_args, logger) {
1555
+ const helpStyle = new StyleBuilder().bg("linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)").color("#495057").padding("15px 20px").rounded("8px").border("1px solid #dee2e6").font("Monaco, Consolas, monospace").size("13px").build();
1556
+ const helpText = `
1557
+ ╭─────────────── ADVANCED LOGGER CLI COMMANDS ─────────────────╮
1558
+ │ │
1559
+ │ CONFIGURATION │
1560
+ │ /config Show current configuration │
1561
+ │ /config {json} Apply JSON configuration │
1562
+ │ /config key=val Apply key-value configuration │
1563
+ │ /themes Show available themes │
1564
+ │ /banners Show available banner types │
1565
+ │ /banner [type] Change/show banner type │
1566
+ │ /status Show logger status & buffer stats │
1567
+ │ /demo Show feature demonstration │
1568
+ │ /reset Reset to default configuration │
1569
+ │ │
1570
+ │ EXPORT & CLIPBOARD │
1571
+ │ /export <format> Export logs (json|csv|md|plain|html) │
1572
+ │ /copy <format> Copy logs to clipboard │
1573
+ │ /buffer-size N Set log buffer size │
1574
+ │ /buffer-info Show buffer statistics │
1575
+ │ /clear-buffer Clear stored logs │
1576
+ │ │
1577
+ │ EXPORT FILTERS (for export/copy commands) │
1578
+ │ --level error,warn Filter by log levels │
1579
+ │ --since 2h Logs from last 2 hours │
1580
+ │ --until 1h Logs until 1 hour ago │
1581
+ │ --prefix API,DB Filter by prefixes │
1582
+ │ --exclude-prefix INT Exclude prefixes │
1583
+ │ --last 50 Last 50 logs only │
1584
+ │ --first 25 First 25 logs only │
1585
+ │ --search "error" Search in log messages │
1586
+ │ --with-stack Only logs with stack traces │
1587
+ │ --errors-only Only error + critical logs │
1588
+ │ --group-by level Group by level/prefix/hour │
1589
+ │ │
1590
+ │ EXPORT OPTIONS │
1591
+ │ --minimal Minimal output format │
1592
+ │ --compact Remove extra whitespace │
1593
+ │ --styled Include styling (HTML format) │
1594
+ │ │
1595
+ ├──────────────────── CONFIGURATION OPTIONS ─────────────────┤
1596
+ │ │
1597
+ │ theme: default | dark | light | neon | minimal | cyberpunk│
1598
+ │ bannerType: simple | ascii | unicode | svg | animated │
1599
+ │ verbosity: debug | info | warn | error | critical | silent│
1600
+ │ enableColors: true | false │
1601
+ │ enableTimestamps: true | false │
1602
+ │ enableStackTrace: true | false │
1603
+ │ globalPrefix: "string" │
1604
+ │ bufferSize: number (50-10000) │
1605
+ │ │
1606
+ ├──────────────────────── EXAMPLES ──────────────────────────┤
1607
+ │ │
1608
+ │ Basic Configuration: │
1609
+ │ /config {"theme":"dark","verbosity":"debug"} │
1610
+ │ /config theme=neon,bufferSize=2000 │
1611
+ │ /banner animated Change to animated banner │
1612
+ │ │
1613
+ │ Export Examples: │
1614
+ │ /export json --level=error,warn --last=25 │
1615
+ │ /export csv --since=2h --prefix=API │
1616
+ │ /export markdown --group-by=level --errors-only │
1617
+ │ /export html --styled --since=1h │
1618
+ │ │
1619
+ │ Clipboard Examples: │
1620
+ │ /copy plain --minimal --last=10 │
1621
+ │ /copy json --search="authentication" --compact │
1622
+ │ /copy csv --since=30m --exclude-prefix=DEBUG │
1623
+ │ │
1624
+ │ Buffer Management: │
1625
+ │ /buffer-size 5000 Increase buffer to 5000 logs │
1626
+ │ /buffer-info Show detailed buffer statistics │
1627
+ │ /clear-buffer Clear all stored logs │
1628
+ │ │
1629
+ │ Time Formats: │
1630
+ │ --since=2h 2 hours ago │
1631
+ │ --since=30m 30 minutes ago │
1632
+ │ --since=1d 1 day ago │
1633
+ │ --since="2024-01-01T10:00:00Z" Specific ISO date │
1634
+ │ │
1635
+ ╰─────────────────────────────────────────────────────────────╯`;
1636
+ console.log(`%c${helpText}`, helpStyle);
1637
+ logger.group("💡 Quick Tips");
1638
+ const tips = [
1639
+ "Use /demo to see all logger features in action",
1640
+ "Logs are automatically stored in a circular buffer for export",
1641
+ "Export formats: JSON (structured), CSV (Excel), Markdown (readable), Plain (simple), HTML (styled)",
1642
+ "Time filters support relative (2h, 30m) and absolute (ISO) formats",
1643
+ 'Combine multiple filters: /export json --level=error --since=1h --search="auth"',
1644
+ "Use /copy for quick clipboard access instead of /export"
1645
+ ];
1646
+ tips.forEach((tip) => {
1647
+ logger.info(`• ${tip}`);
1648
+ });
1649
+ logger.groupEnd();
1650
+ }
1651
+ }
1652
+ class HistoryCommand {
1653
+ name = "history";
1654
+ description = "Show command execution history";
1655
+ usage = "/history [limit] - Show recent commands (default: 10)";
1656
+ category = "system";
1657
+ aliases = ["hist", "h"];
1658
+ execute(args, logger) {
1659
+ const processor = logger.cliProcessor;
1660
+ if (!processor) {
1661
+ logger.error("CLI processor not available");
1662
+ return;
1663
+ }
1664
+ const limit = parseInt(args) || 10;
1665
+ const history = processor.getHistory().slice(0, limit);
1666
+ if (history.length === 0) {
1667
+ logger.info("📝 No command history available");
1668
+ return;
1669
+ }
1670
+ logger.info(`📋 Last ${history.length} commands:`);
1671
+ history.forEach((entry, index) => {
1672
+ const status = entry.success ? "✅" : "❌";
1673
+ const time = entry.timestamp.toLocaleTimeString();
1674
+ logger.info(`${status} [${time}] ${entry.command}`);
1675
+ });
1676
+ }
1677
+ }
1678
+ class ClearHistoryCommand {
1679
+ name = "clearhistory";
1680
+ description = "Clear command execution history";
1681
+ usage = "/clearhistory - Remove all command history";
1682
+ category = "system";
1683
+ aliases = ["clrhist"];
1684
+ execute(args, logger) {
1685
+ const processor = logger.cliProcessor;
1686
+ if (!processor) {
1687
+ logger.error("CLI processor not available");
1688
+ return;
1689
+ }
1690
+ processor.clearHistory();
1691
+ logger.success("🗑️ Command history cleared");
1692
+ }
1693
+ }
1694
+ class InteractiveCommand {
1695
+ name = "interactive";
1696
+ description = "Enter interactive CLI mode";
1697
+ usage = "/interactive - Start interactive command mode";
1698
+ category = "system";
1699
+ aliases = ["i", "repl"];
1700
+ execute(args, logger) {
1701
+ const processor = logger.cliProcessor;
1702
+ if (!processor) {
1703
+ logger.error("CLI processor not available");
1704
+ return;
1705
+ }
1706
+ processor.enterInteractiveMode(logger);
1707
+ }
1708
+ }
1709
+ class PluginsCommand {
1710
+ name = "plugins";
1711
+ description = "List loaded CLI plugins";
1712
+ usage = "/plugins - Show all registered plugins";
1713
+ category = "system";
1714
+ aliases = ["plug"];
1715
+ execute(args, logger) {
1716
+ const processor = logger.cliProcessor;
1717
+ if (!processor) {
1718
+ logger.error("CLI processor not available");
1719
+ return;
1720
+ }
1721
+ const plugins = processor.getPlugins();
1722
+ if (plugins.length === 0) {
1723
+ logger.info("🔌 No plugins registered");
1724
+ return;
1725
+ }
1726
+ logger.info(`🔌 Loaded plugins (${plugins.length}):`);
1727
+ plugins.forEach((plugin) => {
1728
+ logger.info(` 📦 ${plugin.name} v${plugin.version} - ${plugin.description}`);
1729
+ logger.info(` Commands: ${plugin.commands.map((c) => c.name).join(", ")}`);
1730
+ });
1731
+ }
1732
+ }
1733
+ function createDefaultCLI() {
1734
+ const processor = new CommandProcessor();
1735
+ processor.registerCommand(new HelpCommand());
1736
+ processor.registerCommand(new ConfigCommand());
1737
+ processor.registerCommand(new ThemesCommand());
1738
+ processor.registerCommand(new BannersCommand());
1739
+ processor.registerCommand(new BannerCommand());
1740
+ processor.registerCommand(new StatusCommand());
1741
+ processor.registerCommand(new ResetCommand());
1742
+ processor.registerCommand(new DemoCommand());
1743
+ processor.registerCommand(new ExportCommand());
1744
+ processor.registerCommand(new CopyCommand());
1745
+ processor.registerCommand(new BufferSizeCommand());
1746
+ processor.registerCommand(new ClearBufferCommand());
1747
+ processor.registerCommand(new BufferInfoCommand());
1748
+ processor.registerCommand(new HistoryCommand());
1749
+ processor.registerCommand(new ClearHistoryCommand());
1750
+ processor.registerCommand(new InteractiveCommand());
1751
+ processor.registerCommand(new PluginsCommand());
1752
+ return processor;
1753
+ }
1754
+ let LEVEL_STYLES = THEME_PRESETS.default;
1755
+ class Logger {
1756
+ config;
1757
+ scopedPrefix;
1758
+ handlers = [];
1759
+ timers = /* @__PURE__ */ new Map();
1760
+ groupDepth = 0;
1761
+ exportHandler;
1762
+ cliProcessor;
1763
+ /**
1764
+ * Creates a new Logger instance
1765
+ */
1766
+ constructor(config = {}) {
1767
+ this.config = {
1768
+ ...DEFAULT_CONFIG,
1769
+ ...config
1770
+ };
1771
+ if (this.config.bufferSize) {
1772
+ this.exportHandler = new ExportLogHandler(this.config.bufferSize);
1773
+ this.handlers.push(this.exportHandler);
1774
+ }
1775
+ this.cliProcessor = createDefaultCLI();
1776
+ }
1777
+ // ===== CONFIGURATION METHODS =====
1778
+ /**
1779
+ * Get current configuration
1780
+ */
1781
+ getConfig() {
1782
+ return { ...this.config };
1783
+ }
1784
+ /**
1785
+ * Update configuration
1786
+ */
1787
+ updateConfig(updates) {
1788
+ this.config = { ...this.config, ...updates };
1789
+ }
1790
+ /**
1791
+ * Sets the global prefix for all log messages
1792
+ */
1793
+ setGlobalPrefix(prefix) {
1794
+ this.config.globalPrefix = prefix;
1795
+ }
1796
+ /**
1797
+ * Sets the verbosity level for filtering log output
1798
+ */
1799
+ setVerbosity(level) {
1800
+ this.config.verbosity = level;
1801
+ }
1802
+ /**
1803
+ * Sets the logger theme
1804
+ */
1805
+ setTheme(theme) {
1806
+ if (theme in THEME_PRESETS) {
1807
+ LEVEL_STYLES = THEME_PRESETS[theme];
1808
+ this.config.theme = theme;
1809
+ if (theme in THEME_BANNERS) {
1810
+ const themeBanner = THEME_BANNERS[theme];
1811
+ console.log(`%c${themeBanner.simple}`, themeBanner.style);
1812
+ }
1813
+ this.success(`Theme changed to: ${theme}`);
1814
+ } else {
1815
+ this.error(`Invalid theme: ${theme}. Available themes:`, Object.keys(THEME_PRESETS));
1816
+ }
1817
+ }
1818
+ /**
1819
+ * Set banner type for initialization display
1820
+ */
1821
+ setBannerType(bannerType) {
1822
+ this.config.bannerType = bannerType;
1823
+ this.success(`Banner type changed to: ${bannerType}`);
1824
+ }
1825
+ /**
1826
+ * Reset logger to default configuration
1827
+ */
1828
+ resetConfig() {
1829
+ this.config = { ...DEFAULT_CONFIG };
1830
+ LEVEL_STYLES = THEME_PRESETS.default;
1831
+ this.success("Logger configuration reset to defaults");
1832
+ }
1833
+ // ===== SCOPED LOGGER =====
1834
+ /**
1835
+ * Creates a scoped logger with a specific prefix
1836
+ */
1837
+ createScopedLogger(prefix) {
1838
+ const scopedLogger = new Logger(this.config);
1839
+ scopedLogger.scopedPrefix = prefix;
1840
+ scopedLogger.handlers = [...this.handlers];
1841
+ scopedLogger.exportHandler = this.exportHandler;
1842
+ return scopedLogger;
1843
+ }
1844
+ // ===== HANDLER MANAGEMENT =====
1845
+ /**
1846
+ * Adds a custom log handler for extensibility
1847
+ */
1848
+ addHandler(handler) {
1849
+ this.handlers.push(handler);
1850
+ }
1851
+ /**
1852
+ * Get all registered handlers
1853
+ */
1854
+ getHandlers() {
1855
+ return [...this.handlers];
1856
+ }
1857
+ /**
1858
+ * Get export handler if available
1859
+ */
1860
+ getExportHandler() {
1861
+ return this.exportHandler;
1862
+ }
1863
+ // ===== CORE LOGGING METHODS =====
1864
+ /**
1865
+ * Checks if a log level should be output based on current verbosity
1866
+ */
1867
+ shouldLog(level) {
1868
+ if (this.config.verbosity === "silent") return false;
1869
+ const levels = { debug: 0, info: 1, warn: 2, error: 3, critical: 4 };
1870
+ return levels[level] >= levels[this.config.verbosity];
1871
+ }
1872
+ /**
1873
+ * Gets the effective prefix (global + scoped)
1874
+ */
1875
+ getEffectivePrefix() {
1876
+ const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);
1877
+ return parts.length > 0 ? parts.join(":") : void 0;
1878
+ }
1879
+ /**
1880
+ * Core logging method that handles styling and formatting
1881
+ */
1882
+ log(level, ...args) {
1883
+ if (!this.shouldLog(level)) return;
1884
+ const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
1885
+ const prefix = this.getEffectivePrefix();
1886
+ const message = args.length > 0 ? String(args[0]) : "";
1887
+ const additionalArgs = args.slice(1);
1888
+ const [format, ...styles] = createStyledOutput(level, LEVEL_STYLES, prefix, message, stackInfo);
1889
+ const groupIndent = " ".repeat(this.groupDepth);
1890
+ const finalFormat = groupIndent + format;
1891
+ if (additionalArgs.length > 0) {
1892
+ console.log(finalFormat, ...styles, ...additionalArgs);
1893
+ } else {
1894
+ console.log(finalFormat, ...styles);
1895
+ }
1896
+ if (this.exportHandler) {
1897
+ this.exportHandler.setGroupInfo(this.groupDepth);
1898
+ }
1899
+ const metadata = {
1900
+ timestamp: formatTimestamp(),
1901
+ level,
1902
+ prefix,
1903
+ stackInfo: stackInfo ? stackInfo : void 0
1904
+ };
1905
+ this.handlers.forEach((handler) => {
1906
+ try {
1907
+ handler.handle(level, message, args, metadata);
1908
+ } catch (error2) {
1909
+ console.error("Log handler failed:", error2);
1910
+ }
1911
+ });
1912
+ }
1913
+ /**
1914
+ * Logs debug information (lowest priority)
1915
+ */
1916
+ debug(...args) {
1917
+ this.log("debug", ...args);
1918
+ }
1919
+ /**
1920
+ * Logs informational messages
1921
+ */
1922
+ info(...args) {
1923
+ this.log("info", ...args);
1924
+ }
1925
+ /**
1926
+ * Logs warning messages
1927
+ */
1928
+ warn(...args) {
1929
+ this.log("warn", ...args);
1930
+ }
1931
+ /**
1932
+ * Logs error messages
1933
+ */
1934
+ error(...args) {
1935
+ this.log("error", ...args);
1936
+ }
1937
+ /**
1938
+ * Logs success messages (special info level)
1939
+ */
1940
+ success(...args) {
1941
+ if (!this.shouldLog("info")) return;
1942
+ const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
1943
+ const prefix = this.getEffectivePrefix();
1944
+ const message = args.length > 0 ? String(args[0]) : "";
1945
+ const additionalArgs = args.slice(1);
1946
+ const [format, ...styles] = createStyledOutput("info", LEVEL_STYLES, prefix, message, stackInfo);
1947
+ const successStyle = LEVEL_STYLES.success;
1948
+ let emoji = "✅";
1949
+ let label = "SUCCESS";
1950
+ if (successStyle) {
1951
+ if (successStyle.emoji) {
1952
+ emoji = successStyle.emoji;
1953
+ }
1954
+ if (successStyle.label) {
1955
+ label = successStyle.label;
1956
+ }
1957
+ }
1958
+ const successFormat = format.replace(/ℹ️ INFO/, `${emoji} ${label}`);
1959
+ const groupIndent = " ".repeat(this.groupDepth);
1960
+ const finalFormat = groupIndent + successFormat;
1961
+ if (additionalArgs.length > 0) {
1962
+ console.log(finalFormat, ...styles, ...additionalArgs);
1963
+ } else {
1964
+ console.log(finalFormat, ...styles);
1965
+ }
1966
+ const metadata = {
1967
+ timestamp: formatTimestamp(),
1968
+ level: "info",
1969
+ prefix,
1970
+ stackInfo: stackInfo ? stackInfo : void 0
1971
+ };
1972
+ this.handlers.forEach((handler) => {
1973
+ try {
1974
+ handler.handle("info", message, args, metadata);
1975
+ } catch (error2) {
1976
+ console.error("Log handler failed:", error2);
1977
+ }
1978
+ });
1979
+ }
1980
+ /**
1981
+ * Logs trace information (detailed debugging)
1982
+ */
1983
+ trace(...args) {
1984
+ this.log("debug", ...args);
1985
+ if (this.shouldLog("debug")) {
1986
+ console.trace(...args);
1987
+ }
1988
+ }
1989
+ /**
1990
+ * Logs critical errors (highest priority)
1991
+ */
1992
+ critical(...args) {
1993
+ this.log("critical", ...args);
1994
+ }
1995
+ // ===== ADVANCED LOGGING FEATURES =====
1996
+ /**
1997
+ * Displays data in a table format
1998
+ */
1999
+ table(data, columns) {
2000
+ if (!this.shouldLog("info")) return;
2001
+ const prefix = this.getEffectivePrefix();
2002
+ const tableStyle = StylePresets.accent().build();
2003
+ const format = `%c📊 TABLE${prefix ? ` [${prefix}]` : ""}`;
2004
+ console.log(format, tableStyle);
2005
+ if (columns) {
2006
+ console.table(data, columns);
2007
+ } else {
2008
+ console.table(data);
2009
+ }
2010
+ }
2011
+ /**
2012
+ * Starts a collapsible group in the console
2013
+ */
2014
+ group(label, collapsed = false) {
2015
+ const groupStyle = new StyleBuilder().bg("linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%)").color("#1565c0").border("1px solid #90caf9").padding("4px 12px").rounded("6px").bold().build();
2016
+ const format = `%c📁 ${label}`;
2017
+ if (collapsed) {
2018
+ console.groupCollapsed(format, groupStyle);
2019
+ } else {
2020
+ console.group(format, groupStyle);
2021
+ }
2022
+ this.groupDepth++;
2023
+ }
2024
+ /**
2025
+ * Ends the current console group
2026
+ */
2027
+ groupEnd() {
2028
+ if (this.groupDepth > 0) {
2029
+ console.groupEnd();
2030
+ this.groupDepth--;
2031
+ }
2032
+ }
2033
+ // ===== PERFORMANCE TIMING =====
2034
+ /**
2035
+ * Starts a timer with the given label
2036
+ */
2037
+ time(label) {
2038
+ const timer = {
2039
+ label,
2040
+ startTime: performance.now()
2041
+ };
2042
+ this.timers.set(label, timer);
2043
+ const timerStyle = StylePresets.warning().build();
2044
+ console.log(`%c⏱️ Timer started: ${label}`, timerStyle);
2045
+ }
2046
+ /**
2047
+ * Ends a timer and logs the elapsed time
2048
+ */
2049
+ timeEnd(label) {
2050
+ const timer = this.timers.get(label);
2051
+ if (!timer) {
2052
+ this.warn(`Timer '${label}' does not exist`);
2053
+ return;
2054
+ }
2055
+ const elapsed = performance.now() - timer.startTime;
2056
+ this.timers.delete(label);
2057
+ const timerStyle = StylePresets.success().build();
2058
+ console.log(`%c⏱️ Timer ended: ${label} - ${elapsed.toFixed(2)}ms`, timerStyle);
2059
+ }
2060
+ // ===== ADVANCED VISUAL FEATURES =====
2061
+ /**
2062
+ * Display banner with specified or configured type
2063
+ */
2064
+ showBanner(bannerType) {
2065
+ const effectiveBannerType = bannerType ? bannerType : this.config.bannerType;
2066
+ displayInitBanner(effectiveBannerType);
2067
+ }
2068
+ /**
2069
+ * Log with SVG background image
2070
+ */
2071
+ logWithSVG(message, svgContent, options = {}) {
2072
+ const { width = 300, height = 60, padding = "30px 150px" } = options;
2073
+ let svgDataUri = "";
2074
+ if (svgContent) {
2075
+ const encodedSVG = encodeURIComponent(svgContent);
2076
+ svgDataUri = `data:image/svg+xml,${encodedSVG}`;
2077
+ } else {
2078
+ const defaultSVG = `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${width} ${height}'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='0%'><stop offset='0%' style='stop-color:%23667eea'/><stop offset='100%' style='stop-color:%23764ba2'/></linearGradient></defs><rect width='100%' height='100%' fill='url(%23grad)' rx='4'/><text x='${width / 2}' y='${height / 2 + 5}' text-anchor='middle' fill='white' font-family='monospace' font-size='14' font-weight='bold'>${message}</text></svg>`;
2079
+ svgDataUri = `data:image/svg+xml,${encodeURIComponent(defaultSVG)}`;
2080
+ }
2081
+ const svgStyle = new StyleBuilder().bg(`url("${svgDataUri}") no-repeat center center`).padding(padding).color("transparent").rounded("4px").build();
2082
+ console.log(`%c${message}`, svgStyle);
2083
+ }
2084
+ /**
2085
+ * Log with animated background gradient
2086
+ */
2087
+ logAnimated(message, duration = 3) {
2088
+ if (!document.getElementById("logger-animations")) {
2089
+ const style = document.createElement("style");
2090
+ style.id = "logger-animations";
2091
+ style.textContent = `
2092
+ @keyframes loggerGradient {
2093
+ 0% { background-position: 0% 50%; }
2094
+ 50% { background-position: 100% 50%; }
2095
+ 100% { background-position: 0% 50%; }
2096
+ }
2097
+ `;
2098
+ document.head.appendChild(style);
2099
+ }
2100
+ const animatedStyle = new StyleBuilder().bg("linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2)").css("background-size", "400% 400%").color("#ffffff").padding("12px 20px").rounded("8px").bold().font("Monaco, Consolas, monospace").animation(`loggerGradient ${duration}s ease infinite`).display("inline-block").build();
2101
+ console.log(`%c${message}`, animatedStyle);
2102
+ }
2103
+ /**
2104
+ * Groups logs by a specific property using modern Object.groupBy (when available)
2105
+ */
2106
+ logGrouped(items, groupBy) {
2107
+ try {
2108
+ let grouped;
2109
+ if (Object.groupBy) {
2110
+ grouped = Object.groupBy(items, groupBy);
2111
+ } else {
2112
+ grouped = items.reduce((acc, item) => {
2113
+ const key = groupBy(item);
2114
+ if (!acc[key]) {
2115
+ acc[key] = [];
2116
+ }
2117
+ acc[key].push(item);
2118
+ return acc;
2119
+ }, {});
2120
+ }
2121
+ Object.entries(grouped).forEach(([group2, groupItems]) => {
2122
+ this.group(`Group: ${group2}`);
2123
+ this.table(groupItems);
2124
+ this.groupEnd();
2125
+ });
2126
+ } catch {
2127
+ this.info("Grouped data:", items);
2128
+ }
2129
+ }
2130
+ // ===== CLI SYSTEM =====
2131
+ /**
2132
+ * CLI command processor for logger configuration and export
2133
+ */
2134
+ async cli(command) {
2135
+ if (!this.cliProcessor) {
2136
+ this.error("CLI processor not initialized");
2137
+ return;
2138
+ }
2139
+ await this.cliProcessor.processCommand(command, this);
2140
+ }
2141
+ }
2142
+ new Logger({
2143
+ verbosity: "info",
2144
+ enableColors: true,
2145
+ enableTimestamps: true,
2146
+ enableStackTrace: true,
2147
+ bufferSize: 1e3
2148
+ // Enable export functionality by default
2149
+ });
2150
+ displayInitBanner();
2151
+ export {
2152
+ BANNER_VARIANTS as B,
2153
+ ExportLogHandler as E,
2154
+ Logger as L,
2155
+ THEME_PRESETS as T,
2156
+ THEME_BANNERS as a,
2157
+ displayInitBanner as d
2158
+ };
2159
+ //# sourceMappingURL=Logger-CVwk8cgA.js.map