@mks2508/better-logger 5.0.0 → 5.0.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 (190) hide show
  1. package/CHANGELOG.json +45 -1
  2. package/package.json +1 -1
  3. package/packages/core/package.json +1 -1
  4. package/packages/exports/package.json +2 -2
  5. package/packages/styling/package.json +2 -2
  6. package/src/terminal/formatter.ts +16 -10
  7. package/bun.lock +0 -333
  8. package/dist/Logger.d.ts +0 -976
  9. package/dist/Logger.d.ts.map +0 -1
  10. package/dist/ScopedLogger.d.ts +0 -74
  11. package/dist/ScopedLogger.d.ts.map +0 -1
  12. package/dist/chunks/Logger-BZ7B7OXE.js +0 -4511
  13. package/dist/chunks/Logger-BZ7B7OXE.js.map +0 -1
  14. package/dist/chunks/Logger-Cbi1f10o.js +0 -2
  15. package/dist/chunks/Logger-Cbi1f10o.js.map +0 -1
  16. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +0 -33
  17. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +0 -1
  18. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +0 -2
  19. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +0 -1
  20. package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
  21. package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
  22. package/dist/chunks/cli-module-ClIJmaT8.js +0 -383
  23. package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
  24. package/dist/chunks/color-converter-CCSQRztd.js +0 -2
  25. package/dist/chunks/color-converter-CCSQRztd.js.map +0 -1
  26. package/dist/chunks/color-converter-_Xdmsy7E.js +0 -462
  27. package/dist/chunks/color-converter-_Xdmsy7E.js.map +0 -1
  28. package/dist/chunks/environment-C1xxvc8l.js +0 -1127
  29. package/dist/chunks/environment-C1xxvc8l.js.map +0 -1
  30. package/dist/chunks/environment-Cprkw3g9.js +0 -4
  31. package/dist/chunks/environment-Cprkw3g9.js.map +0 -1
  32. package/dist/chunks/formatting-DMJxYq9o.js +0 -380
  33. package/dist/chunks/formatting-DMJxYq9o.js.map +0 -1
  34. package/dist/chunks/formatting-DpKxCsXq.js +0 -2
  35. package/dist/chunks/formatting-DpKxCsXq.js.map +0 -1
  36. package/dist/cli/CommandProcessor.d.ts +0 -100
  37. package/dist/cli/CommandProcessor.d.ts.map +0 -1
  38. package/dist/cli/commands/ConfigCommand.d.ts +0 -14
  39. package/dist/cli/commands/ConfigCommand.d.ts.map +0 -1
  40. package/dist/cli/commands/ExportCommand.d.ts +0 -48
  41. package/dist/cli/commands/ExportCommand.d.ts.map +0 -1
  42. package/dist/cli/commands/HistoryCommand.d.ts +0 -47
  43. package/dist/cli/commands/HistoryCommand.d.ts.map +0 -1
  44. package/dist/cli/commands/StatusCommand.d.ts +0 -30
  45. package/dist/cli/commands/StatusCommand.d.ts.map +0 -1
  46. package/dist/cli/commands/ThemeCommand.d.ts +0 -30
  47. package/dist/cli/commands/ThemeCommand.d.ts.map +0 -1
  48. package/dist/cli/help.d.ts +0 -12
  49. package/dist/cli/help.d.ts.map +0 -1
  50. package/dist/cli/index.d.ts +0 -15
  51. package/dist/cli/index.d.ts.map +0 -1
  52. package/dist/cli-module.d.ts +0 -15
  53. package/dist/cli-module.d.ts.map +0 -1
  54. package/dist/cli-primitives/box.d.ts +0 -11
  55. package/dist/cli-primitives/box.d.ts.map +0 -1
  56. package/dist/cli-primitives/cli-table.d.ts +0 -11
  57. package/dist/cli-primitives/cli-table.d.ts.map +0 -1
  58. package/dist/cli-primitives/divider.d.ts +0 -11
  59. package/dist/cli-primitives/divider.d.ts.map +0 -1
  60. package/dist/cli-primitives/header.d.ts +0 -12
  61. package/dist/cli-primitives/header.d.ts.map +0 -1
  62. package/dist/cli-primitives/index.d.ts +0 -13
  63. package/dist/cli-primitives/index.d.ts.map +0 -1
  64. package/dist/cli-primitives/server-fallback.d.ts +0 -25
  65. package/dist/cli-primitives/server-fallback.d.ts.map +0 -1
  66. package/dist/cli-primitives/spinner.d.ts +0 -47
  67. package/dist/cli-primitives/spinner.d.ts.map +0 -1
  68. package/dist/cli-primitives/step.d.ts +0 -11
  69. package/dist/cli-primitives/step.d.ts.map +0 -1
  70. package/dist/cli.cjs +0 -2
  71. package/dist/cli.cjs.map +0 -1
  72. package/dist/cli.js +0 -12
  73. package/dist/cli.js.map +0 -1
  74. package/dist/constants.d.ts +0 -235
  75. package/dist/constants.d.ts.map +0 -1
  76. package/dist/core.cjs +0 -2
  77. package/dist/core.cjs.map +0 -1
  78. package/dist/core.d.ts +0 -127
  79. package/dist/core.d.ts.map +0 -1
  80. package/dist/core.js +0 -291
  81. package/dist/core.js.map +0 -1
  82. package/dist/example.d.ts +0 -18
  83. package/dist/example.d.ts.map +0 -1
  84. package/dist/exports-module.d.ts +0 -196
  85. package/dist/exports-module.d.ts.map +0 -1
  86. package/dist/exports.cjs +0 -2
  87. package/dist/exports.cjs.map +0 -1
  88. package/dist/exports.js +0 -238
  89. package/dist/exports.js.map +0 -1
  90. package/dist/handlers/AnalyticsLogHandler.d.ts +0 -8
  91. package/dist/handlers/AnalyticsLogHandler.d.ts.map +0 -1
  92. package/dist/handlers/ExportLogHandler.d.ts +0 -100
  93. package/dist/handlers/ExportLogHandler.d.ts.map +0 -1
  94. package/dist/handlers/FileLogHandler.d.ts +0 -33
  95. package/dist/handlers/FileLogHandler.d.ts.map +0 -1
  96. package/dist/handlers/RemoteLogHandler.d.ts +0 -11
  97. package/dist/handlers/RemoteLogHandler.d.ts.map +0 -1
  98. package/dist/handlers/index.d.ts +0 -8
  99. package/dist/handlers/index.d.ts.map +0 -1
  100. package/dist/hooks/HookManager.d.ts +0 -21
  101. package/dist/hooks/HookManager.d.ts.map +0 -1
  102. package/dist/hooks/index.d.ts +0 -2
  103. package/dist/hooks/index.d.ts.map +0 -1
  104. package/dist/index.cjs +0 -2
  105. package/dist/index.cjs.map +0 -1
  106. package/dist/index.d.ts +0 -161
  107. package/dist/index.d.ts.map +0 -1
  108. package/dist/index.js +0 -627
  109. package/dist/index.js.map +0 -1
  110. package/dist/main.d.ts +0 -2
  111. package/dist/main.d.ts.map +0 -1
  112. package/dist/serializers/SerializerRegistry.d.ts +0 -16
  113. package/dist/serializers/SerializerRegistry.d.ts.map +0 -1
  114. package/dist/serializers/index.d.ts +0 -2
  115. package/dist/serializers/index.d.ts.map +0 -1
  116. package/dist/styling/LogStyleBuilder.d.ts +0 -146
  117. package/dist/styling/LogStyleBuilder.d.ts.map +0 -1
  118. package/dist/styling/SemanticStyles.d.ts +0 -178
  119. package/dist/styling/SemanticStyles.d.ts.map +0 -1
  120. package/dist/styling/SmartPresets.d.ts +0 -22
  121. package/dist/styling/SmartPresets.d.ts.map +0 -1
  122. package/dist/styling/StyleBuilder.d.ts +0 -140
  123. package/dist/styling/StyleBuilder.d.ts.map +0 -1
  124. package/dist/styling/StyleCache.d.ts +0 -42
  125. package/dist/styling/StyleCache.d.ts.map +0 -1
  126. package/dist/styling/banners.d.ts +0 -42
  127. package/dist/styling/banners.d.ts.map +0 -1
  128. package/dist/styling/index.d.ts +0 -10
  129. package/dist/styling/index.d.ts.map +0 -1
  130. package/dist/styling/themes.d.ts +0 -7
  131. package/dist/styling/themes.d.ts.map +0 -1
  132. package/dist/styling-module.d.ts +0 -178
  133. package/dist/styling-module.d.ts.map +0 -1
  134. package/dist/styling.cjs +0 -2
  135. package/dist/styling.cjs.map +0 -1
  136. package/dist/styling.js +0 -146
  137. package/dist/styling.js.map +0 -1
  138. package/dist/terminal/color-converter.d.ts +0 -73
  139. package/dist/terminal/color-converter.d.ts.map +0 -1
  140. package/dist/terminal/formatter.d.ts +0 -20
  141. package/dist/terminal/formatter.d.ts.map +0 -1
  142. package/dist/terminal/terminal-renderer.d.ts +0 -77
  143. package/dist/terminal/terminal-renderer.d.ts.map +0 -1
  144. package/dist/transports/ConsoleTransport.d.ts +0 -9
  145. package/dist/transports/ConsoleTransport.d.ts.map +0 -1
  146. package/dist/transports/FileTransport.d.ts +0 -15
  147. package/dist/transports/FileTransport.d.ts.map +0 -1
  148. package/dist/transports/HttpTransport.d.ts +0 -16
  149. package/dist/transports/HttpTransport.d.ts.map +0 -1
  150. package/dist/transports/TransportManager.d.ts +0 -14
  151. package/dist/transports/TransportManager.d.ts.map +0 -1
  152. package/dist/transports/index.d.ts +0 -5
  153. package/dist/transports/index.d.ts.map +0 -1
  154. package/dist/types/core.d.ts +0 -380
  155. package/dist/types/core.d.ts.map +0 -1
  156. package/dist/types/handlers.d.ts +0 -85
  157. package/dist/types/handlers.d.ts.map +0 -1
  158. package/dist/types/hooks.d.ts +0 -36
  159. package/dist/types/hooks.d.ts.map +0 -1
  160. package/dist/types/index.d.ts +0 -11
  161. package/dist/types/index.d.ts.map +0 -1
  162. package/dist/types/serializers.d.ts +0 -25
  163. package/dist/types/serializers.d.ts.map +0 -1
  164. package/dist/types/transports.d.ts +0 -47
  165. package/dist/types/transports.d.ts.map +0 -1
  166. package/dist/utils/adapter.d.ts +0 -48
  167. package/dist/utils/adapter.d.ts.map +0 -1
  168. package/dist/utils/ansi-colors.d.ts +0 -156
  169. package/dist/utils/ansi-colors.d.ts.map +0 -1
  170. package/dist/utils/environment-detector.d.ts +0 -45
  171. package/dist/utils/environment-detector.d.ts.map +0 -1
  172. package/dist/utils/environment.d.ts +0 -47
  173. package/dist/utils/environment.d.ts.map +0 -1
  174. package/dist/utils/formatting.d.ts +0 -58
  175. package/dist/utils/formatting.d.ts.map +0 -1
  176. package/dist/utils/index.d.ts +0 -8
  177. package/dist/utils/index.d.ts.map +0 -1
  178. package/dist/utils/opentui-detection.d.ts +0 -34
  179. package/dist/utils/opentui-detection.d.ts.map +0 -1
  180. package/dist/utils/output.d.ts +0 -46
  181. package/dist/utils/output.d.ts.map +0 -1
  182. package/dist/utils/stackTrace.d.ts +0 -6
  183. package/dist/utils/stackTrace.d.ts.map +0 -1
  184. package/dist/utils/timestamps.d.ts +0 -20
  185. package/dist/utils/timestamps.d.ts.map +0 -1
  186. package/dist/vite.svg +0 -1
  187. package/dist/writers/BufferWriter.d.ts +0 -96
  188. package/dist/writers/BufferWriter.d.ts.map +0 -1
  189. package/dist/writers/index.d.ts +0 -6
  190. package/dist/writers/index.d.ts.map +0 -1
package/dist/index.js DELETED
@@ -1,627 +0,0 @@
1
- import { L as Logger } from "./chunks/Logger-BZ7B7OXE.js";
2
- import { A, B, C, e, H, c, S, a, T, b } from "./chunks/Logger-BZ7B7OXE.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-ClIJmaT8.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