@mks2508/better-logger 2.0.0 → 2.1.0

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 (125) hide show
  1. package/bun.lock +333 -0
  2. package/dist/Logger.d.ts +704 -0
  3. package/dist/Logger.d.ts.map +1 -0
  4. package/dist/ScopedLogger.d.ts +310 -0
  5. package/dist/ScopedLogger.d.ts.map +1 -0
  6. package/dist/chunks/Logger-B7L-ujY4.js +3503 -0
  7. package/dist/chunks/Logger-B7L-ujY4.js.map +1 -0
  8. package/dist/chunks/Logger-DzU_c5sX.js +2 -0
  9. package/dist/chunks/Logger-DzU_c5sX.js.map +1 -0
  10. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  11. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  12. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  13. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  14. package/dist/chunks/ScopedLogger-BY3-E8Ov.js +2 -0
  15. package/dist/chunks/ScopedLogger-BY3-E8Ov.js.map +1 -0
  16. package/dist/chunks/ScopedLogger-D-RbiFZn.js +361 -0
  17. package/dist/chunks/ScopedLogger-D-RbiFZn.js.map +1 -0
  18. package/dist/chunks/environment-Ba5kShbx.js +4 -0
  19. package/dist/chunks/environment-Ba5kShbx.js.map +1 -0
  20. package/dist/chunks/environment-TI2ByCPT.js +1209 -0
  21. package/dist/chunks/environment-TI2ByCPT.js.map +1 -0
  22. package/dist/chunks/formatting-Blwy-f0W.js +2 -0
  23. package/dist/chunks/formatting-Blwy-f0W.js.map +1 -0
  24. package/dist/chunks/formatting-CuNUqGks.js +380 -0
  25. package/dist/chunks/formatting-CuNUqGks.js.map +1 -0
  26. package/dist/cli/CommandProcessor.d.ts +100 -0
  27. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  28. package/dist/cli/commands/ConfigCommand.d.ts +14 -0
  29. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  30. package/dist/cli/commands/ExportCommand.d.ts +48 -0
  31. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  32. package/dist/cli/commands/HistoryCommand.d.ts +47 -0
  33. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  34. package/dist/cli/commands/StatusCommand.d.ts +30 -0
  35. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  36. package/dist/cli/commands/ThemeCommand.d.ts +30 -0
  37. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  38. package/dist/cli/help.d.ts +12 -0
  39. package/dist/cli/help.d.ts.map +1 -0
  40. package/dist/cli/index.d.ts +15 -0
  41. package/dist/cli/index.d.ts.map +1 -0
  42. package/dist/constants.d.ts +227 -0
  43. package/dist/constants.d.ts.map +1 -0
  44. package/dist/core.cjs +2 -0
  45. package/dist/core.cjs.map +1 -0
  46. package/dist/core.d.ts +127 -0
  47. package/dist/core.d.ts.map +1 -0
  48. package/dist/core.js +291 -0
  49. package/dist/core.js.map +1 -0
  50. package/dist/example.d.ts +18 -0
  51. package/dist/example.d.ts.map +1 -0
  52. package/dist/exports-module.d.ts +196 -0
  53. package/dist/exports-module.d.ts.map +1 -0
  54. package/dist/exports.cjs +2 -0
  55. package/dist/exports.cjs.map +1 -0
  56. package/dist/exports.js +238 -0
  57. package/dist/exports.js.map +1 -0
  58. package/dist/handlers/AnalyticsLogHandler.d.ts +8 -0
  59. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  60. package/dist/handlers/ExportLogHandler.d.ts +100 -0
  61. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  62. package/dist/handlers/FileLogHandler.d.ts +33 -0
  63. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  64. package/dist/handlers/RemoteLogHandler.d.ts +11 -0
  65. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  66. package/dist/handlers/index.d.ts +8 -0
  67. package/dist/handlers/index.d.ts.map +1 -0
  68. package/dist/index.cjs +2 -0
  69. package/dist/index.cjs.map +1 -0
  70. package/dist/index.d.ts +124 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +247 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/main.d.ts +2 -0
  75. package/dist/main.d.ts.map +1 -0
  76. package/dist/styling/LogStyleBuilder.d.ts +146 -0
  77. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  78. package/dist/styling/SemanticStyles.d.ts +178 -0
  79. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  80. package/dist/styling/SmartPresets.d.ts +22 -0
  81. package/dist/styling/SmartPresets.d.ts.map +1 -0
  82. package/dist/styling/StyleBuilder.d.ts +140 -0
  83. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  84. package/dist/styling/banners.d.ts +42 -0
  85. package/dist/styling/banners.d.ts.map +1 -0
  86. package/dist/styling/index.d.ts +10 -0
  87. package/dist/styling/index.d.ts.map +1 -0
  88. package/dist/styling/themes.d.ts +7 -0
  89. package/dist/styling/themes.d.ts.map +1 -0
  90. package/dist/styling-module.d.ts +178 -0
  91. package/dist/styling-module.d.ts.map +1 -0
  92. package/dist/styling.cjs +2 -0
  93. package/dist/styling.cjs.map +1 -0
  94. package/dist/styling.js +146 -0
  95. package/dist/styling.js.map +1 -0
  96. package/dist/terminal/terminal-renderer.d.ts +63 -0
  97. package/dist/terminal/terminal-renderer.d.ts.map +1 -0
  98. package/dist/types/core.d.ts +234 -0
  99. package/dist/types/core.d.ts.map +1 -0
  100. package/dist/types/handlers.d.ts +85 -0
  101. package/dist/types/handlers.d.ts.map +1 -0
  102. package/dist/types/index.d.ts +7 -0
  103. package/dist/types/index.d.ts.map +1 -0
  104. package/dist/utils/adapter.d.ts +48 -0
  105. package/dist/utils/adapter.d.ts.map +1 -0
  106. package/dist/utils/ansi-colors.d.ts +156 -0
  107. package/dist/utils/ansi-colors.d.ts.map +1 -0
  108. package/dist/utils/environment-detector.d.ts +35 -0
  109. package/dist/utils/environment-detector.d.ts.map +1 -0
  110. package/dist/utils/environment.d.ts +47 -0
  111. package/dist/utils/environment.d.ts.map +1 -0
  112. package/dist/utils/formatting.d.ts +58 -0
  113. package/dist/utils/formatting.d.ts.map +1 -0
  114. package/dist/utils/index.d.ts +8 -0
  115. package/dist/utils/index.d.ts.map +1 -0
  116. package/dist/utils/opentui-detection.d.ts +34 -0
  117. package/dist/utils/opentui-detection.d.ts.map +1 -0
  118. package/dist/utils/output.d.ts +46 -0
  119. package/dist/utils/output.d.ts.map +1 -0
  120. package/dist/utils/stackTrace.d.ts +6 -0
  121. package/dist/utils/stackTrace.d.ts.map +1 -0
  122. package/dist/utils/timestamps.d.ts +20 -0
  123. package/dist/utils/timestamps.d.ts.map +1 -0
  124. package/dist/vite.svg +1 -0
  125. package/package.json +1 -1
@@ -0,0 +1,238 @@
1
+ import { L as Logger, E as ExportLogHandler } from "./chunks/Logger-B7L-ujY4.js";
2
+ import "./chunks/environment-TI2ByCPT.js";
3
+ import { R as RemoteLogHandler } from "./chunks/RemoteLogHandler-CjWpWZGl.js";
4
+ class ExportLogger extends Logger {
5
+ exportLogHandler;
6
+ remoteHandlers = [];
7
+ constructor(config = {}) {
8
+ super(config);
9
+ if (config.bufferSize) {
10
+ this.exportLogHandler = new ExportLogHandler(config.bufferSize);
11
+ this.addHandler(this.exportLogHandler);
12
+ }
13
+ }
14
+ /**
15
+ * Export logs in specified format
16
+ *
17
+ * @param format - Export format (csv, json, xml)
18
+ * @param options - Export options
19
+ * @returns Promise resolving to exported data
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const csvData = await logger.exportLogs('csv');
24
+ * const jsonData = await logger.exportLogs('json', {
25
+ * filter: { level: 'error' },
26
+ * limit: 100
27
+ * });
28
+ * ```
29
+ */
30
+ async exportLogs(format, options) {
31
+ if (!this.exportLogHandler) {
32
+ throw new Error("Export handler not initialized. Set bufferSize in constructor.");
33
+ }
34
+ return JSON.stringify([]);
35
+ }
36
+ /**
37
+ * Get current log buffer
38
+ *
39
+ * @returns Array of log entries
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const logs = logger.getLogs();
44
+ * console.log(`Buffered ${logs.length} log entries`);
45
+ * ```
46
+ */
47
+ getLogs() {
48
+ if (!this.exportLogHandler) {
49
+ return [];
50
+ }
51
+ return [];
52
+ }
53
+ /**
54
+ * Clear the log buffer
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * logger.clearLogs();
59
+ * ```
60
+ */
61
+ clearLogs() {
62
+ if (this.exportLogHandler) ;
63
+ }
64
+ /**
65
+ * Get log statistics
66
+ *
67
+ * @returns Statistics object with counts by level
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const stats = logger.getLogStats();
72
+ * console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);
73
+ * ```
74
+ */
75
+ getLogStats() {
76
+ if (!this.exportLogHandler) {
77
+ return {};
78
+ }
79
+ return {};
80
+ }
81
+ /**
82
+ * Add remote logging handler
83
+ *
84
+ * @param endpoint - Remote endpoint URL
85
+ * @param apiKey - Optional API key for authentication
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');
90
+ * ```
91
+ */
92
+ addRemoteHandler(endpoint, apiKey) {
93
+ const remoteHandler = new RemoteLogHandler(endpoint, apiKey);
94
+ this.remoteHandlers.push(remoteHandler);
95
+ this.addHandler(remoteHandler);
96
+ }
97
+ /**
98
+ * Remove all remote handlers
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * logger.clearRemoteHandlers();
103
+ * ```
104
+ */
105
+ clearRemoteHandlers() {
106
+ const allHandlers = this.getHandlers();
107
+ this.remoteHandlers.forEach((remoteHandler) => {
108
+ const index = allHandlers.indexOf(remoteHandler);
109
+ if (index > -1) {
110
+ allHandlers.splice(index, 1);
111
+ }
112
+ });
113
+ this.remoteHandlers = [];
114
+ }
115
+ /**
116
+ * Flush all remote handlers (force send pending logs)
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * await logger.flushRemoteHandlers();
121
+ * ```
122
+ */
123
+ async flushRemoteHandlers() {
124
+ const flushPromises = this.remoteHandlers.map(
125
+ (handler) => Promise.resolve()
126
+ // RemoteLogHandler needs flush method
127
+ );
128
+ await Promise.all(flushPromises);
129
+ }
130
+ }
131
+ const exportLogger = new ExportLogger({ bufferSize: 1e3 });
132
+ const exportUtils = {
133
+ /**
134
+ * Export current logs as CSV
135
+ */
136
+ async exportCSV(options) {
137
+ return await exportLogger.exportLogs("csv", options);
138
+ },
139
+ /**
140
+ * Export current logs as JSON
141
+ */
142
+ async exportJSON(options) {
143
+ return await exportLogger.exportLogs("json", options);
144
+ },
145
+ /**
146
+ * Export current logs as XML
147
+ */
148
+ async exportXML(options) {
149
+ return await exportLogger.exportLogs("xml", options);
150
+ },
151
+ /**
152
+ * Get log statistics
153
+ */
154
+ getStats() {
155
+ return exportLogger.getLogStats();
156
+ },
157
+ /**
158
+ * Clear all logs
159
+ */
160
+ clear() {
161
+ exportLogger.clearLogs();
162
+ }
163
+ };
164
+ const remoteUtils = {
165
+ /**
166
+ * Add remote logging endpoint
167
+ */
168
+ addEndpoint(url, apiKey) {
169
+ exportLogger.addRemoteHandler(url, apiKey);
170
+ },
171
+ /**
172
+ * Clear all remote endpoints
173
+ */
174
+ clearEndpoints() {
175
+ exportLogger.clearRemoteHandlers();
176
+ },
177
+ /**
178
+ * Flush all remote logs
179
+ */
180
+ async flush() {
181
+ await exportLogger.flushRemoteHandlers();
182
+ }
183
+ };
184
+ const debug = (...args) => exportLogger.debug(...args);
185
+ const info = (...args) => exportLogger.info(...args);
186
+ const warn = (...args) => exportLogger.warn(...args);
187
+ const error = (...args) => exportLogger.error(...args);
188
+ const success = (...args) => exportLogger.success(...args);
189
+ const critical = (...args) => exportLogger.critical(...args);
190
+ const trace = (...args) => exportLogger.trace(...args);
191
+ const table = (data, columns) => exportLogger.table(data, columns);
192
+ const group = (label, collapsed) => exportLogger.group(label, collapsed);
193
+ const groupEnd = () => exportLogger.groupEnd();
194
+ const time = (label) => exportLogger.time(label);
195
+ const timeEnd = (label) => exportLogger.timeEnd(label);
196
+ const setGlobalPrefix = (prefix) => exportLogger.setGlobalPrefix(prefix);
197
+ const scope = (prefix) => exportLogger.scope(prefix);
198
+ const setVerbosity = (level) => exportLogger.setVerbosity(level);
199
+ const addHandler = (handler) => exportLogger.addHandler(handler);
200
+ const exportLogs = async (format, options) => await exportLogger.exportLogs(format, options);
201
+ const getLogs = () => exportLogger.getLogs();
202
+ const clearLogs = () => exportLogger.clearLogs();
203
+ const getLogStats = () => exportLogger.getLogStats();
204
+ const addRemoteHandler = (endpoint, apiKey) => exportLogger.addRemoteHandler(endpoint, apiKey);
205
+ const clearRemoteHandlers = () => exportLogger.clearRemoteHandlers();
206
+ const flushRemoteHandlers = async () => await exportLogger.flushRemoteHandlers();
207
+ export {
208
+ ExportLogHandler,
209
+ ExportLogger,
210
+ RemoteLogHandler,
211
+ addHandler,
212
+ addRemoteHandler,
213
+ clearLogs,
214
+ clearRemoteHandlers,
215
+ critical,
216
+ debug,
217
+ exportLogger as default,
218
+ error,
219
+ exportLogs,
220
+ exportUtils,
221
+ flushRemoteHandlers,
222
+ getLogStats,
223
+ getLogs,
224
+ group,
225
+ groupEnd,
226
+ info,
227
+ remoteUtils,
228
+ scope,
229
+ setGlobalPrefix,
230
+ setVerbosity,
231
+ success,
232
+ table,
233
+ time,
234
+ timeEnd,
235
+ trace,
236
+ warn
237
+ };
238
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sources":["../src/exports-module.ts"],"sourcesContent":["/**\n * @fileoverview Exports Module - Export and remote logging capabilities\n * @version 0.0.1\n * \n * This module provides export functionality for logs including CSV, JSON, XML formats\n * and remote logging capabilities for sending logs to external services.\n */\n\n// Core logger and types\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ILogHandler\n} from './types/index.js';\n\n// Export handlers\nimport {\n ExportLogHandler,\n RemoteLogHandler\n} from './handlers/index.js';\n\n/**\n * Logger with export and remote capabilities\n * \n * @example\n * ```typescript\n * import { ExportLogger } from '@mks2508/better-logger/exports';\n * \n * const logger = new ExportLogger({ bufferSize: 1000 });\n * \n * // Log some data\n * logger.info('User logged in', { userId: 123 });\n * logger.error('Failed to process', { error: 'timeout' });\n * \n * // Export logs\n * const csvData = await logger.exportLogs('csv');\n * const jsonData = await logger.exportLogs('json');\n * \n * // Setup remote logging\n * logger.addRemoteHandler('https://api.myapp.com/logs', 'api-key');\n * ```\n */\nexport class ExportLogger extends Logger {\n private exportLogHandler?: ExportLogHandler;\n private remoteHandlers: RemoteLogHandler[] = [];\n\n constructor(config: { bufferSize?: number } & any = {}) {\n super(config);\n \n // Initialize export handler if buffer size specified\n if (config.bufferSize) {\n this.exportLogHandler = new ExportLogHandler(config.bufferSize);\n this.addHandler(this.exportLogHandler);\n }\n }\n\n /**\n * Export logs in specified format\n * \n * @param format - Export format (csv, json, xml)\n * @param options - Export options\n * @returns Promise resolving to exported data\n * \n * @example\n * ```typescript\n * const csvData = await logger.exportLogs('csv');\n * const jsonData = await logger.exportLogs('json', { \n * filter: { level: 'error' },\n * limit: 100 \n * });\n * ```\n */\n async exportLogs(\n format: 'csv' | 'json' | 'xml', \n options?: {\n filter?: { level?: LogLevel; from?: Date; to?: Date };\n limit?: number;\n }\n ): Promise<string> {\n if (!this.exportLogHandler) {\n throw new Error('Export handler not initialized. Set bufferSize in constructor.');\n }\n\n // Temporary implementation - ExportLogHandler needs these methods\n return JSON.stringify([]);\n }\n\n /**\n * Get current log buffer\n * \n * @returns Array of log entries\n * \n * @example\n * ```typescript\n * const logs = logger.getLogs();\n * console.log(`Buffered ${logs.length} log entries`);\n * ```\n */\n getLogs(): any[] {\n if (!this.exportLogHandler) {\n return [];\n }\n \n // Temporary implementation - ExportLogHandler needs these methods\n return [];\n }\n\n /**\n * Clear the log buffer\n * \n * @example\n * ```typescript\n * logger.clearLogs();\n * ```\n */\n clearLogs(): void {\n if (this.exportLogHandler) {\n // Temporary implementation - ExportLogHandler needs these methods\n }\n }\n\n /**\n * Get log statistics\n * \n * @returns Statistics object with counts by level\n * \n * @example\n * ```typescript\n * const stats = logger.getLogStats();\n * console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);\n * ```\n */\n getLogStats(): Record<string, number> {\n if (!this.exportLogHandler) {\n return {};\n }\n\n // Temporary implementation - ExportLogHandler needs these methods\n return {};\n }\n\n /**\n * Add remote logging handler\n * \n * @param endpoint - Remote endpoint URL\n * @param apiKey - Optional API key for authentication\n * \n * @example\n * ```typescript\n * logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');\n * ```\n */\n addRemoteHandler(endpoint: string, apiKey?: string): void {\n const remoteHandler = new RemoteLogHandler(endpoint, apiKey);\n this.remoteHandlers.push(remoteHandler);\n this.addHandler(remoteHandler);\n }\n\n /**\n * Remove all remote handlers\n * \n * @example\n * ```typescript\n * logger.clearRemoteHandlers();\n * ```\n */\n clearRemoteHandlers(): void {\n // Remove from handlers array\n const allHandlers = this.getHandlers();\n this.remoteHandlers.forEach(remoteHandler => {\n const index = allHandlers.indexOf(remoteHandler);\n if (index > -1) {\n allHandlers.splice(index, 1);\n }\n });\n \n this.remoteHandlers = [];\n }\n\n /**\n * Flush all remote handlers (force send pending logs)\n * \n * @example\n * ```typescript\n * await logger.flushRemoteHandlers();\n * ```\n */\n async flushRemoteHandlers(): Promise<void> {\n const flushPromises = this.remoteHandlers.map(handler => \n Promise.resolve() // RemoteLogHandler needs flush method\n );\n \n await Promise.all(flushPromises);\n }\n}\n\n// Create singleton instance with export capabilities\nconst exportLogger = new ExportLogger({ bufferSize: 1000 });\n\n/**\n * Export management utilities\n */\nexport const exportUtils = {\n /**\n * Export current logs as CSV\n */\n async exportCSV(options?: any): Promise<string> {\n return await exportLogger.exportLogs('csv', options);\n },\n\n /**\n * Export current logs as JSON\n */\n async exportJSON(options?: any): Promise<string> {\n return await exportLogger.exportLogs('json', options);\n },\n\n /**\n * Export current logs as XML\n */\n async exportXML(options?: any): Promise<string> {\n return await exportLogger.exportLogs('xml', options);\n },\n\n /**\n * Get log statistics\n */\n getStats(): Record<string, number> {\n return exportLogger.getLogStats();\n },\n\n /**\n * Clear all logs\n */\n clear(): void {\n exportLogger.clearLogs();\n }\n};\n\n/**\n * Remote logging utilities\n */\nexport const remoteUtils = {\n /**\n * Add remote logging endpoint\n */\n addEndpoint(url: string, apiKey?: string): void {\n exportLogger.addRemoteHandler(url, apiKey);\n },\n\n /**\n * Clear all remote endpoints\n */\n clearEndpoints(): void {\n exportLogger.clearRemoteHandlers();\n },\n\n /**\n * Flush all remote logs\n */\n async flush(): Promise<void> {\n await exportLogger.flushRemoteHandlers();\n }\n};\n\n/**\n * Export individual logging methods with export capabilities\n */\nexport const debug = (...args: any[]) => exportLogger.debug(...args);\nexport const info = (...args: any[]) => exportLogger.info(...args);\nexport const warn = (...args: any[]) => exportLogger.warn(...args);\nexport const error = (...args: any[]) => exportLogger.error(...args);\nexport const success = (...args: any[]) => exportLogger.success(...args);\nexport const critical = (...args: any[]) => exportLogger.critical(...args);\nexport const trace = (...args: any[]) => exportLogger.trace(...args);\nexport const table = (data: any, columns?: string[]) => exportLogger.table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => exportLogger.group(label, collapsed);\nexport const groupEnd = () => exportLogger.groupEnd();\nexport const time = (label: string) => exportLogger.time(label);\nexport const timeEnd = (label: string) => exportLogger.timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => exportLogger.setGlobalPrefix(prefix);\nexport const scope = (prefix: string) => exportLogger.scope(prefix);\nexport const setVerbosity = (level: Verbosity) => exportLogger.setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => exportLogger.addHandler(handler);\n\n/**\n * Export functionality\n */\nexport const exportLogs = async (format: 'csv' | 'json' | 'xml', options?: any) => \n await exportLogger.exportLogs(format, options);\nexport const getLogs = () => exportLogger.getLogs();\nexport const clearLogs = () => exportLogger.clearLogs();\nexport const getLogStats = () => exportLogger.getLogStats();\n\n/**\n * Remote logging functionality\n */\nexport const addRemoteHandler = (endpoint: string, apiKey?: string) => \n exportLogger.addRemoteHandler(endpoint, apiKey);\nexport const clearRemoteHandlers = () => exportLogger.clearRemoteHandlers();\nexport const flushRemoteHandlers = async () => await exportLogger.flushRemoteHandlers();\n\n// Export the singleton as default\nexport default exportLogger;\n\n// Re-export handlers\nexport { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';\n\n// Re-export types\nexport type { ILogHandler } from './types/index.js';"],"names":[],"mappings":";;;AA2CO,MAAM,qBAAqB,OAAO;AAAA,EAC7B;AAAA,EACA,iBAAqC,CAAA;AAAA,EAE7C,YAAY,SAAwC,IAAI;AACpD,UAAM,MAAM;AAGZ,QAAI,OAAO,YAAY;AACnB,WAAK,mBAAmB,IAAI,iBAAiB,OAAO,UAAU;AAC9D,WAAK,WAAW,KAAK,gBAAgB;AAAA,IACzC;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,WACF,QACA,SAIe;AACf,QAAI,CAAC,KAAK,kBAAkB;AACxB,YAAM,IAAI,MAAM,gEAAgE;AAAA,IACpF;AAGA,WAAO,KAAK,UAAU,EAAE;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,UAAiB;AACb,QAAI,CAAC,KAAK,kBAAkB;AACxB,aAAO,CAAA;AAAA,IACX;AAGA,WAAO,CAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,YAAkB;AACd,QAAI,KAAK,iBAAkB;AAAA,EAG/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,cAAsC;AAClC,QAAI,CAAC,KA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,WAAW,OAAO;AAK5E,MAAM,aAAa,OAAO,QAAgC,YAC7D,MAAM,aAAa,WAAW,QAAQ,OAAO;AAC1C,MAAM,UAAU,MAAM,aAAa,QAAA;AACnC,MAAM,YAAY,MAAM,aAAa,UAAA;AACrC,MAAM,cAAc,MAAM,aAAa,YAAA;AAKvC,MAAM,mBAAmB,CAAC,UAAkB,WAC/C,aAAa,iBAAiB,UAAU,MAAM;AAC3C,MAAM,sBAAsB,MAAM,aAAa,oBAAA;AAC/C,MAAM,sBAAsB,YAAY,MAAM,aAAa,oBAAA;"}
@@ -0,0 +1,8 @@
1
+ import { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';
2
+ /**
3
+ * Example custom handler for analytics demonstration
4
+ */
5
+ export declare class AnalyticsLogHandler implements ILogHandler {
6
+ handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void;
7
+ }
8
+ //# sourceMappingURL=AnalyticsLogHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsLogHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/AnalyticsLogHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5E;;GAEG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IACnD,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI;CAWtF"}
@@ -0,0 +1,100 @@
1
+ import { ILogHandler, LogLevel, LogMetadata, LogEntry, ExportFilters, ExportOptions, ExportResult, BufferStats, ExportFormat } from '../types/index.js';
2
+ /**
3
+ * Export log handler with circular buffer and multiple export formats
4
+ */
5
+ export declare class ExportLogHandler implements ILogHandler {
6
+ private buffer;
7
+ private maxSize;
8
+ private groupDepth;
9
+ private currentGroup?;
10
+ constructor(maxSize?: number);
11
+ /**
12
+ * Handle incoming log and store in buffer
13
+ */
14
+ handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void;
15
+ /**
16
+ * Set group tracking for nested logs
17
+ */
18
+ setGroupInfo(depth: number, groupName?: string): void;
19
+ /**
20
+ * Get buffer statistics
21
+ */
22
+ getBufferStats(): BufferStats;
23
+ /**
24
+ * Clear the buffer
25
+ */
26
+ clearBuffer(): void;
27
+ /**
28
+ * Set buffer size (with limits)
29
+ */
30
+ setBufferSize(size: number): void;
31
+ /**
32
+ * Filter logs based on criteria
33
+ */
34
+ private filterLogs;
35
+ /**
36
+ * Export logs in JSON format
37
+ */
38
+ private exportJSON;
39
+ /**
40
+ * Export logs in CSV format
41
+ */
42
+ private exportCSV;
43
+ /**
44
+ * Export logs in Markdown format
45
+ */
46
+ private exportMarkdown;
47
+ /**
48
+ * Export logs in plain text format
49
+ */
50
+ private exportPlain;
51
+ /**
52
+ * Export logs in HTML format
53
+ */
54
+ private exportHTML;
55
+ /**
56
+ * Get emoji for log level
57
+ */
58
+ private getLevelEmoji;
59
+ /**
60
+ * Main export function
61
+ */
62
+ export(format: ExportFormat, filters?: ExportFilters, options?: ExportOptions): ExportResult;
63
+ /**
64
+ * Copy to clipboard with fallback
65
+ */
66
+ copyToClipboard(format: ExportFormat, filters?: ExportFilters, options?: ExportOptions): Promise<boolean>;
67
+ /**
68
+ * Get all logs (for debugging)
69
+ */
70
+ getAllLogs(): LogEntry[];
71
+ /**
72
+ * Save export to file with download prompt
73
+ */
74
+ saveToFile(format: ExportFormat, filters?: ExportFilters, options?: ExportOptions): Promise<boolean>;
75
+ /**
76
+ * Get MIME type for format
77
+ */
78
+ private getMimeType;
79
+ /**
80
+ * Generate filename with timestamp
81
+ */
82
+ private generateFilename;
83
+ /**
84
+ * Stream logs to external endpoint
85
+ */
86
+ streamToEndpoint(endpoint: string, filters?: ExportFilters, options?: {
87
+ apiKey?: string;
88
+ batchSize?: number;
89
+ format?: ExportFormat;
90
+ }): Promise<boolean>;
91
+ /**
92
+ * Create export with metadata enrichment
93
+ */
94
+ exportWithMetadata(format: ExportFormat, filters?: ExportFilters, options?: ExportOptions): ExportResult;
95
+ /**
96
+ * Estimate memory usage of buffer
97
+ */
98
+ private estimateMemoryUsage;
99
+ }
100
+ //# sourceMappingURL=ExportLogHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportLogHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/ExportLogHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACf,MAAM,mBAAmB,CAAC;AAK3B;;GAEG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAChD,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,OAAO,GAAE,MAAmC;IAIxD;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI;IAsBlF;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAKrD;;OAEG;IACH,cAAc,IAAI,WAAW;IAuC7B;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IASjC;;OAEG;IACH,OAAO,CAAC,UAAU;IAkElB;;OAEG;IACH,OAAO,CAAC,UAAU;IAkBlB;;OAEG;IACH,OAAO,CAAC,SAAS;IA2BjB;;OAEG;IACH,OAAO,CAAC,cAAc;IAsDtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,UAAU;IA2DlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY;IAqCpG;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BvH;;OAEG;IACH,UAAU,IAAI,QAAQ,EAAE;IAIxB;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BlH;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,EAAE,OAAO,GAAE;QAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,YAAY,CAAA;KACnB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4CzB;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY;IAsBhH;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAQ9B"}
@@ -0,0 +1,33 @@
1
+ import { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';
2
+ /**
3
+ * Universal file-based log handler for persistent logging
4
+ * Works in both Node.js (real files) and browser (localStorage)
5
+ */
6
+ export declare class FileLogHandler implements ILogHandler {
7
+ private filename;
8
+ private maxSize?;
9
+ private fs?;
10
+ constructor(filename?: string, maxSize?: number);
11
+ handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void;
12
+ /**
13
+ * Format log entry as a single line for file storage
14
+ */
15
+ private formatLogLine;
16
+ /**
17
+ * Write to actual file in Node.js environment
18
+ */
19
+ private writeToFileNode;
20
+ /**
21
+ * Write to localStorage in browser environment
22
+ */
23
+ private writeToFileLocal;
24
+ /**
25
+ * Get stored logs (useful for debugging)
26
+ */
27
+ getLogs(): string | null;
28
+ /**
29
+ * Clear stored logs
30
+ */
31
+ clearLogs(): void;
32
+ }
33
+ //# sourceMappingURL=FileLogHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileLogHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/FileLogHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI5E;;;GAGG;AACH,qBAAa,cAAe,YAAW,WAAW;IAC9C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,EAAE,CAAC,CAAM;gBAEL,QAAQ,GAAE,MAAkB,EAAE,OAAO,CAAC,EAAE,MAAM;IAc1D,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI;IAsBlF;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAyBvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;OAEG;IACH,OAAO,IAAI,MAAM,GAAG,IAAI;IAcxB;;OAEG;IACH,SAAS,IAAI,IAAI;CAYpB"}
@@ -0,0 +1,11 @@
1
+ import { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';
2
+ /**
3
+ * Remote log handler for sending logs to external services
4
+ */
5
+ export declare class RemoteLogHandler implements ILogHandler {
6
+ private endpoint;
7
+ private apiKey?;
8
+ constructor(endpoint: string, apiKey?: string);
9
+ handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=RemoteLogHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteLogHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/RemoteLogHandler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5E;;GAEG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAChD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAKvC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBpG"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @fileoverview Log handlers exports for Advanced Logger
3
+ */
4
+ export { FileLogHandler } from './FileLogHandler.js';
5
+ export { RemoteLogHandler } from './RemoteLogHandler.js';
6
+ export { AnalyticsLogHandler } from './AnalyticsLogHandler.js';
7
+ export { ExportLogHandler } from './ExportLogHandler.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-DzU_c5sX.js"),t=require("./chunks/environment-Ba5kShbx.js"),r=require("./chunks/formatting-Blwy-f0W.js"),o=require("./chunks/RemoteLogHandler-ymkQ97xl.js");let s=null;function getLogger(){return s||(s=new e.Logger),s}const i=getLogger(),a={success:t.StylePresets.success().build(),error:t.StylePresets.error().build(),warning:t.StylePresets.warning().build(),info:t.StylePresets.info().build(),accent:t.StylePresets.accent().build()};exports.BANNER_VARIANTS=e.BANNER_VARIANTS,exports.Logger=e.Logger,exports.THEME_BANNERS=e.THEME_BANNERS,exports.THEME_PRESETS=e.THEME_PRESETS,exports.BUILD_PRESETS=t.BUILD_PRESETS,exports.DEFAULT_CONFIG=t.DEFAULT_CONFIG,exports.ENVIRONMENT_DETECTION=t.ENVIRONMENT_DETECTION,exports.StyleBuilder=t.StyleBuilder,exports.StylePresets=t.StylePresets,exports.detectEnvironmentPreset=t.detectEnvironmentPreset,exports.formatTimestamp=t.formatTimestamp,exports.getOptimalConfig=t.getOptimalConfig,exports.parseStackTrace=t.parseStackTrace,exports.BUILD_FORMATTERS=r.BUILD_FORMATTERS,exports.ansiBackground=r.ansiBackground,exports.ansiBold=r.ansiBold,exports.ansiColor=r.ansiColor,exports.ansiDim=r.ansiDim,exports.ansiStyle=r.ansiStyle,exports.ansiUnderline=r.ansiUnderline,exports.createANSIOutput=r.createANSIOutput,exports.createBuildOutput=r.createBuildOutput,exports.createCIOutput=r.createCIOutput,exports.createOutput=r.createOutput,exports.detectOptimalFormat=r.detectOptimalFormat,exports.formatLogLevelANSI=r.formatLogLevelANSI,exports.formatSuccessANSI=r.formatSuccessANSI,exports.sanitizeEmojis=r.sanitizeEmojis,exports.RemoteLogHandler=o.RemoteLogHandler,exports.AnalyticsLogHandler=class{handle(e,t,r,o){"error"!==e&&"critical"!==e||o.timestamp}},exports.FileLogHandler=class{filename;maxSize;fs;constructor(e="app.log",r){if(this.filename=e,this.maxSize=r,t.isNode)try{this.fs=require("fs")}catch(o){console.warn("FileLogHandler: Unable to load fs module:",o)}}handle(e,o,s,i){const a={timestamp:i.timestamp,level:e.toUpperCase(),prefix:i.prefix,message:o,args:s.slice(1).map(e=>r.safeSerialize(e)),location:i.stackInfo},l=this.formatLogLine(a);t.isNode&&this.fs?this.writeToFileNode(l):t.isBrowser?this.writeToFileLocal(l):console.log(`[FILE-LOG] ${l}`)}formatLogLine(e){let t=[e.timestamp,`[${e.level}]`,e.prefix?`[${e.prefix}]`:"",e.message].filter(Boolean).join(" ");return e.args&&e.args.length>0&&(t+=" "+e.args.map(e=>"object"==typeof e?JSON.stringify(e):String(e)).join(" ")),e.location&&(t+=` (${e.location.file}:${e.location.line}:${e.location.column})`),t}writeToFileNode(e){if(this.fs)try{if(this.maxSize)try{if(this.fs.statSync(this.filename).size>this.maxSize){const e=`${this.filename}.bak`;this.fs.renameSync(this.filename,e)}}catch(t){}this.fs.appendFileSync(this.filename,e+"\n","utf8")}catch(t){console.error("FileLogHandler: Failed to write to file:",t)}}writeToFileLocal(e){try{const t=`logger_${this.filename}`,r=localStorage.getItem(t)||"";let o=r;if(r.length>0&&(o+="\n"),o+=e,this.maxSize||o.split("\n").length>1e3){const e=o.split("\n"),t=this.maxSize?Math.floor(this.maxSize/100):1e3;e.length>t&&(o=e.slice(-t).join("\n"))}localStorage.setItem(t,o)}catch(t){console.error("FileLogHandler: Failed to write to localStorage:",t)}}getLogs(){if(t.isNode&&this.fs)try{return this.fs.readFileSync(this.filename,"utf8")}catch(e){return null}else if(t.isBrowser){const e=`logger_${this.filename}`;return localStorage.getItem(e)}return null}clearLogs(){if(t.isNode&&this.fs)try{this.fs.writeFileSync(this.filename,"","utf8")}catch(e){console.error("FileLogHandler: Failed to clear file:",e)}else if(t.isBrowser){const e=`logger_${this.filename}`;localStorage.removeItem(e)}}},exports.addHandler=e=>getLogger().addHandler(e),exports.cli=e=>getLogger().cli(e),exports.createStyle=()=>new t.StyleBuilder,exports.critical=(...e)=>getLogger().critical(...e),exports.debug=(...e)=>getLogger().debug(...e),exports.default=i,exports.error=(...e)=>getLogger().error(...e),exports.group=(e,t)=>getLogger().group(e,t),exports.groupEnd=()=>getLogger().groupEnd(),exports.info=(...e)=>getLogger().info(...e),exports.logAnimated=(e,t)=>getLogger().logAnimated(e,t),exports.logWithSVG=(e,t,r)=>getLogger().logWithSVG(e,t,r),exports.scope=e=>getLogger().scope(e),exports.setBannerType=e=>getLogger().setBannerType(e),exports.setGlobalPrefix=e=>getLogger().setGlobalPrefix(e),exports.setTheme=e=>getLogger().setTheme(e),exports.setVerbosity=e=>getLogger().setVerbosity(e),exports.showBanner=e=>getLogger().showBanner(e),exports.stylePresets=a,exports.success=(...e)=>getLogger().success(...e),exports.table=(e,t)=>getLogger().table(e,t),exports.time=e=>getLogger().time(e),exports.timeEnd=e=>getLogger().timeEnd(e),exports.trace=(...e)=>getLogger().trace(...e),exports.warn=(...e)=>getLogger().warn(...e);
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts","../src/handlers/AnalyticsLogHandler.ts","../src/handlers/FileLogHandler.ts"],"sourcesContent":["/**\n * @fileoverview Better Logger - Librería completa con todas las características\n * @version 0.3.0\n * @since 2024\n * \n * Punto de entrada principal que proporciona la experiencia completa de Better Logger\n * con características avanzadas incluyendo estilos CSS, soporte SVG, animaciones,\n * capacidades de exportación y logging remoto.\n * \n * @module @mks2508/better-logger\n */\n\n// Main Logger class with all features\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler\n} from './types/index.js';\n\n// Lazy singleton - se inicializa solo cuando se necesita\nlet _logger: Logger | null = null;\n\nfunction getLogger(): Logger {\n if (!_logger) {\n _logger = new Logger();\n }\n return _logger;\n}\n\n/**\n * Clase principal Logger con conjunto completo de características\n * \n * @example\n * // Importación y uso básico\n * import { Logger } from '@mks2508/better-logger';\n * \n * const logger = new Logger();\n * logger.preset('cyberpunk'); // Aplicar preset completo\n * logger.info('¡Hola mundo!');\n * \n * @example\n * // Logger con scope para componentes\n * const auth = logger.component('Auth');\n * auth.info('Usuario autenticando...');\n * auth.success('Login exitoso');\n * \n * @example\n * // Logger para APIs con badges\n * const api = logger.api('GraphQL');\n * api.badges(['v2', 'cached']).info('Query ejecutada');\n * \n * @since 0.3.0\n */\nexport { Logger };\n\n/**\n * Instancia singleton del logger lista para usar\n * @default\n * \n * @example\n * // Uso directo sin crear instancia\n * import logger from '@mks2508/better-logger';\n * \n * logger.info('Aplicación iniciada');\n * logger.success('Conexión establecida');\n * logger.warn('Memoria al 80%');\n * logger.error('Fallo en conexión');\n */\nexport default getLogger();\n\n/**\n * Métodos de logging individuales (enlazados al singleton)\n * \n * @example\n * // Importar solo los métodos necesarios\n * import { info, error, success } from '@mks2508/better-logger';\n * \n * info('Proceso iniciado');\n * success('✓ Completado exitosamente');\n * error('Error:', errorDetails);\n * \n * @since 0.3.0\n */\nexport const debug = (...args: any[]) => getLogger().debug(...args);\nexport const info = (...args: any[]) => getLogger().info(...args);\nexport const warn = (...args: any[]) => getLogger().warn(...args);\nexport const error = (...args: any[]) => getLogger().error(...args);\nexport const success = (...args: any[]) => getLogger().success(...args);\nexport const critical = (...args: any[]) => getLogger().critical(...args);\nexport const trace = (...args: any[]) => getLogger().trace(...args);\nexport const table = (data: any, columns?: string[]) => getLogger().table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => getLogger().group(label, collapsed);\nexport const groupEnd = () => getLogger().groupEnd();\nexport const time = (label: string) => getLogger().time(label);\nexport const timeEnd = (label: string) => getLogger().timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => getLogger().setGlobalPrefix(prefix);\nexport const scope = (prefix: string) => getLogger().scope(prefix);\nexport const setVerbosity = (level: Verbosity) => getLogger().setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => getLogger().addHandler(handler);\nexport const setTheme = (theme: ThemeVariant) => getLogger().setTheme(theme);\nexport const setBannerType = (bannerType: BannerType) => getLogger().setBannerType(bannerType);\nexport const showBanner = (bannerType?: BannerType) => getLogger().showBanner(bannerType);\nexport const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) => \n getLogger().logWithSVG(message, svgContent, options);\nexport const logAnimated = (message: string, duration?: number) => \n getLogger().logAnimated(message, duration);\nexport const cli = (command: string) => getLogger().cli(command);\n\n// Type exports\nexport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler,\n LoggerConfig,\n LogMetadata,\n StackInfo,\n TimerEntry,\n OutputFormat\n} from './types/index.js';\n\n// Styling utilities\nexport { \n StyleBuilder,\n StylePresets,\n THEME_PRESETS,\n THEME_BANNERS,\n BANNER_VARIANTS\n} from './styling/index.js';\n\n// Handler exports\nexport {\n FileLogHandler,\n RemoteLogHandler,\n AnalyticsLogHandler\n} from './handlers/index.js';\n\n// Constants\nexport { DEFAULT_CONFIG } from './constants.js';\n\n// Utility exports\nexport {\n parseStackTrace,\n formatTimestamp,\n detectOptimalFormat,\n createOutput,\n createANSIOutput,\n createBuildOutput,\n createCIOutput\n} from './utils/index.js';\n\n// ANSI color utilities\nexport {\n ansiStyle,\n ansiColor,\n ansiBackground,\n ansiBold,\n ansiDim,\n ansiUnderline,\n formatLogLevelANSI,\n formatSuccessANSI,\n BUILD_FORMATTERS,\n sanitizeEmojis\n} from './utils/ansi-colors.js';\n\n// Environment detection and presets\nexport {\n BUILD_PRESETS,\n ENVIRONMENT_DETECTION,\n detectEnvironmentPreset,\n getOptimalConfig\n} from './constants.js';\n\n/**\n * Utilidades de estilo para crear estilos personalizados de consola\n * \n * @example\n * // Crear estilo personalizado\n * import { createStyle, stylePresets } from '@mks2508/better-logger';\n * \n * const miEstilo = createStyle()\n * .bg('linear-gradient(45deg, #ff6b6b, #feca57)')\n * .color('white')\n * .padding('10px')\n * .rounded('8px')\n * .bold()\n * .build();\n * \n * console.log('%cMensaje estilizado', miEstilo);\n * \n * @example\n * // Usar presets predefinidos\n * console.log('%cÉxito!', stylePresets.success);\n * console.log('%cError!', stylePresets.error);\n * \n * @since 0.3.0\n */\nimport { StyleBuilder, StylePresets } from './styling/index.js';\n\n/**\n * Crea una nueva instancia de StyleBuilder para estilos personalizados de consola\n * \n * @returns {StyleBuilder} Constructor de estilos encadenable\n * \n * @example\n * const estilo = createStyle()\n * .gradient('#667eea', '#764ba2')\n * .color('white')\n * .padding('8px 16px')\n * .rounded('4px')\n * .shadow('0 2px 4px rgba(0,0,0,0.2)')\n * .build();\n * \n * @since 0.3.0\n */\nexport const createStyle = () => new StyleBuilder();\n\n/**\n * Presets de estilo predefinidos para casos de uso comunes\n * \n * @constant {Object} stylePresets\n * \n * @example\n * console.log('%cOperación exitosa', stylePresets.success);\n * console.log('%cAdvertencia', stylePresets.warning);\n * console.log('%cError crítico', stylePresets.error);\n * console.log('%cInformación', stylePresets.info);\n * console.log('%cDestacado', stylePresets.accent);\n * \n * @since 0.3.0\n */\nexport const stylePresets = {\n success: StylePresets.success().build(),\n error: StylePresets.error().build(),\n warning: StylePresets.warning().build(),\n info: StylePresets.info().build(),\n accent: StylePresets.accent().build(),\n};","/**\n * @fileoverview Analytics log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * Example custom handler for analytics demonstration\n */\nexport class AnalyticsLogHandler implements ILogHandler {\n handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {\n // In a real implementation, this could send analytics data\n if (level === 'error' || level === 'critical') {\n // Track errors for analytics\n console.debug('Analytics: Error tracked', { \n level, \n message, \n timestamp: metadata.timestamp \n });\n }\n }\n}","/**\n * @fileoverview File-based log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\nimport { isNode, isBrowser } from '../utils/environment.js';\nimport { safeSerialize } from '../utils/formatting.js';\n\n/**\n * Universal file-based log handler for persistent logging\n * Works in both Node.js (real files) and browser (localStorage)\n */\nexport class FileLogHandler implements ILogHandler {\n private filename: string;\n private maxSize?: number;\n private fs?: any; // Node.js fs module\n\n constructor(filename: string = 'app.log', maxSize?: number) {\n this.filename = filename;\n this.maxSize = maxSize;\n \n // Load Node.js fs module if in Node environment\n if (isNode) {\n try {\n this.fs = require('fs');\n } catch (error) {\n console.warn('FileLogHandler: Unable to load fs module:', error);\n }\n }\n }\n\n handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void {\n const logEntry = {\n timestamp: metadata.timestamp,\n level: level.toUpperCase(),\n prefix: metadata.prefix,\n message,\n args: args.slice(1).map(arg => safeSerialize(arg)),\n location: metadata.stackInfo,\n };\n\n const logLine = this.formatLogLine(logEntry);\n\n if (isNode && this.fs) {\n this.writeToFileNode(logLine);\n } else if (isBrowser) {\n this.writeToFileLocal(logLine);\n } else {\n // Fallback - just console output\n console.log(`[FILE-LOG] ${logLine}`);\n }\n }\n\n /**\n * Format log entry as a single line for file storage\n */\n private formatLogLine(entry: any): string {\n const parts = [\n entry.timestamp,\n `[${entry.level}]`,\n entry.prefix ? `[${entry.prefix}]` : '',\n entry.message\n ].filter(Boolean);\n\n let line = parts.join(' ');\n \n if (entry.args && entry.args.length > 0) {\n line += ' ' + entry.args.map((arg: any) => \n typeof arg === 'object' ? JSON.stringify(arg) : String(arg)\n ).join(' ');\n }\n \n if (entry.location) {\n line += ` (${entry.location.file}:${entry.location.line}:${entry.location.column})`;\n }\n \n return line;\n }\n\n /**\n * Write to actual file in Node.js environment\n */\n private writeToFileNode(logLine: string): void {\n if (!this.fs) return;\n\n try {\n // Check file size if maxSize is set\n if (this.maxSize) {\n try {\n const stats = this.fs.statSync(this.filename);\n if (stats.size > this.maxSize) {\n // Simple rotation: backup current file and start fresh\n const backupName = `${this.filename}.bak`;\n this.fs.renameSync(this.filename, backupName);\n }\n } catch (error) {\n // File doesn't exist yet, that's fine\n }\n }\n\n // Append to file\n this.fs.appendFileSync(this.filename, logLine + '\\n', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to write to file:', error);\n }\n }\n\n /**\n * Write to localStorage in browser environment\n */\n private writeToFileLocal(logLine: string): void {\n try {\n const storageKey = `logger_${this.filename}`;\n const existingLogs = localStorage.getItem(storageKey) || '';\n \n let newLogs = existingLogs;\n if (existingLogs.length > 0) {\n newLogs += '\\n';\n }\n newLogs += logLine;\n \n // Simple size management - keep last 1000 lines max\n if (this.maxSize || newLogs.split('\\n').length > 1000) {\n const lines = newLogs.split('\\n');\n const maxLines = this.maxSize ? Math.floor(this.maxSize / 100) : 1000;\n if (lines.length > maxLines) {\n newLogs = lines.slice(-maxLines).join('\\n');\n }\n }\n \n localStorage.setItem(storageKey, newLogs);\n } catch (error) {\n console.error('FileLogHandler: Failed to write to localStorage:', error);\n }\n }\n\n /**\n * Get stored logs (useful for debugging)\n */\n getLogs(): string | null {\n if (isNode && this.fs) {\n try {\n return this.fs.readFileSync(this.filename, 'utf8');\n } catch (error) {\n return null;\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n return localStorage.getItem(storageKey);\n }\n return null;\n }\n\n /**\n * Clear stored logs\n */\n clearLogs(): void {\n if (isNode && this.fs) {\n try {\n this.fs.writeFileSync(this.filename, '', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to clear file:', error);\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n localStorage.removeItem(storageKey);\n }\n }\n}"],"names":["_logger","getLogger","Logger","index","stylePresets","success","StylePresets","build","error","warning","info","accent","handle","level","message","_args","metadata","timestamp","filename","maxSize","fs","constructor","this","isNode","require","console","warn","args","logEntry","toUpperCase","prefix","slice","map","arg","safeSerialize","location","stackInfo","logLine","formatLogLine","writeToFileNode","isBrowser","writeToFileLocal","log","entry","line","filter","Boolean","join","length","JSON","stringify","String","file","column","statSync","size","backupName","renameSync","appendFileSync","storageKey","existingLogs","localStorage","getItem","newLogs","split","lines","maxLines","Math","floor","setItem","getLogs","readFileSync","clearLogs","writeFileSync","removeItem","handler","addHandler","command","cli","StyleBuilder","critical","debug","label","collapsed","group","groupEnd","duration","logAnimated","svgContent","options","logWithSVG","scope","bannerType","setBannerType","setGlobalPrefix","theme","setTheme","setVerbosity","showBanner","data","columns","table","time","timeEnd","trace"],"mappings":"ySAwBA,IAAIA,EAAyB,KAE7B,SAASC,YAIL,OAHKD,IACDA,EAAU,IAAIE,EAAAA,QAEXF,CACX,CAyCA,MAAAG,EAAeF,YAqKFG,EAAe,CACxBC,QAASC,EAAAA,aAAaD,UAAUE,QAChCC,MAAOF,EAAAA,aAAaE,QAAQD,QAC5BE,QAASH,EAAAA,aAAaG,UAAUF,QAChCG,KAAMJ,EAAAA,aAAaI,OAAOH,QAC1BI,OAAQL,EAAAA,aAAaK,SAASJ,+qCCzO3B,MACH,MAAAK,CAAOC,EAAiBC,EAAiBC,EAAcC,GAErC,UAAVH,GAA+B,aAAVA,GAKNG,EAASC,SAGhC,0BCRG,MACKC,SACAC,QACAC,GAER,WAAAC,CAAYH,EAAmB,UAAWC,GAKtC,GAJAG,KAAKJ,SAAWA,EAChBI,KAAKH,QAAUA,EAGXI,SACA,IACID,KAAKF,GAAKI,QAAQ,KACtB,OAAShB,GACLiB,QAAQC,KAAK,4CAA6ClB,EAC9D,CAER,CAEA,MAAAI,CAAOC,EAAiBC,EAAiBa,EAAaX,GAClD,MAAMY,EAAW,CACbX,UAAWD,EAASC,UACpBJ,MAAOA,EAAMgB,cACbC,OAAQd,EAASc,OACjBhB,UACAa,KAAMA,EAAKI,MAAM,GAAGC,IAAIC,GAAOC,gBAAcD,IAC7CE,SAAUnB,EAASoB,WAGjBC,EAAUf,KAAKgB,cAAcV,GAE/BL,EAAAA,QAAUD,KAAKF,GACfE,KAAKiB,gBAAgBF,GACdG,EAAAA,UACPlB,KAAKmB,iBAAiBJ,GAGtBZ,QAAQiB,IAAI,cA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F,GAAqBZ,YAAYgG,aAAapF,sBAIhD+E,GAA4B3F,YAAYiG,WAAWN,0CAdvD,IAAIjE,IAAgB1B,YAAYI,WAAWsB,iBAG7C,CAACwE,EAAWC,IAAuBnG,YAAYoG,MAAMF,EAAMC,gBAG3DlB,GAAkBjF,YAAYqG,KAAKpB,mBAChCA,GAAkBjF,YAAYsG,QAAQrB,iBALzC,IAAIvD,IAAgB1B,YAAYuG,SAAS7E,gBAJ1C,IAAIA,IAAgB1B,YAAYyB,QAAQC"}
@@ -0,0 +1,124 @@
1
+ import { Logger } from './Logger.js';
2
+ import { Verbosity, ThemeVariant, BannerType, StyleOptions, ILogHandler } from './types/index.js';
3
+ import { StyleBuilder } from './styling/index.js';
4
+ /**
5
+ * Clase principal Logger con conjunto completo de características
6
+ *
7
+ * @example
8
+ * // Importación y uso básico
9
+ * import { Logger } from '@mks2508/better-logger';
10
+ *
11
+ * const logger = new Logger();
12
+ * logger.preset('cyberpunk'); // Aplicar preset completo
13
+ * logger.info('¡Hola mundo!');
14
+ *
15
+ * @example
16
+ * // Logger con scope para componentes
17
+ * const auth = logger.component('Auth');
18
+ * auth.info('Usuario autenticando...');
19
+ * auth.success('Login exitoso');
20
+ *
21
+ * @example
22
+ * // Logger para APIs con badges
23
+ * const api = logger.api('GraphQL');
24
+ * api.badges(['v2', 'cached']).info('Query ejecutada');
25
+ *
26
+ * @since 0.3.0
27
+ */
28
+ export { Logger };
29
+ /**
30
+ * Instancia singleton del logger lista para usar
31
+ * @default
32
+ *
33
+ * @example
34
+ * // Uso directo sin crear instancia
35
+ * import logger from '@mks2508/better-logger';
36
+ *
37
+ * logger.info('Aplicación iniciada');
38
+ * logger.success('Conexión establecida');
39
+ * logger.warn('Memoria al 80%');
40
+ * logger.error('Fallo en conexión');
41
+ */
42
+ declare const _default: Logger;
43
+ export default _default;
44
+ /**
45
+ * Métodos de logging individuales (enlazados al singleton)
46
+ *
47
+ * @example
48
+ * // Importar solo los métodos necesarios
49
+ * import { info, error, success } from '@mks2508/better-logger';
50
+ *
51
+ * info('Proceso iniciado');
52
+ * success('✓ Completado exitosamente');
53
+ * error('Error:', errorDetails);
54
+ *
55
+ * @since 0.3.0
56
+ */
57
+ export declare const debug: (...args: any[]) => void;
58
+ export declare const info: (...args: any[]) => void;
59
+ export declare const warn: (...args: any[]) => void;
60
+ export declare const error: (...args: any[]) => void;
61
+ export declare const success: (...args: any[]) => void;
62
+ export declare const critical: (...args: any[]) => void;
63
+ export declare const trace: (...args: any[]) => void;
64
+ export declare const table: (data: any, columns?: string[]) => void;
65
+ export declare const group: (label: string, collapsed?: boolean) => void;
66
+ export declare const groupEnd: () => void;
67
+ export declare const time: (label: string) => void;
68
+ export declare const timeEnd: (label: string) => void;
69
+ export declare const setGlobalPrefix: (prefix: string) => void;
70
+ export declare const scope: (prefix: string) => any;
71
+ export declare const setVerbosity: (level: Verbosity) => void;
72
+ export declare const addHandler: (handler: ILogHandler) => void;
73
+ export declare const setTheme: (theme: ThemeVariant) => void;
74
+ export declare const setBannerType: (bannerType: BannerType) => void;
75
+ export declare const showBanner: (bannerType?: BannerType) => void;
76
+ export declare const logWithSVG: (message: string, svgContent?: string, options?: StyleOptions) => void;
77
+ export declare const logAnimated: (message: string, duration?: number) => void;
78
+ export declare const cli: (command: string) => Promise<void>;
79
+ export type { LogLevel, Verbosity, ThemeVariant, BannerType, StyleOptions, ILogHandler, LoggerConfig, LogMetadata, StackInfo, TimerEntry, OutputFormat } from './types/index.js';
80
+ export { StyleBuilder, StylePresets, THEME_PRESETS, THEME_BANNERS, BANNER_VARIANTS } from './styling/index.js';
81
+ export { FileLogHandler, RemoteLogHandler, AnalyticsLogHandler } from './handlers/index.js';
82
+ export { DEFAULT_CONFIG } from './constants.js';
83
+ export { parseStackTrace, formatTimestamp, detectOptimalFormat, createOutput, createANSIOutput, createBuildOutput, createCIOutput } from './utils/index.js';
84
+ export { ansiStyle, ansiColor, ansiBackground, ansiBold, ansiDim, ansiUnderline, formatLogLevelANSI, formatSuccessANSI, BUILD_FORMATTERS, sanitizeEmojis } from './utils/ansi-colors.js';
85
+ export { BUILD_PRESETS, ENVIRONMENT_DETECTION, detectEnvironmentPreset, getOptimalConfig } from './constants.js';
86
+ /**
87
+ * Crea una nueva instancia de StyleBuilder para estilos personalizados de consola
88
+ *
89
+ * @returns {StyleBuilder} Constructor de estilos encadenable
90
+ *
91
+ * @example
92
+ * const estilo = createStyle()
93
+ * .gradient('#667eea', '#764ba2')
94
+ * .color('white')
95
+ * .padding('8px 16px')
96
+ * .rounded('4px')
97
+ * .shadow('0 2px 4px rgba(0,0,0,0.2)')
98
+ * .build();
99
+ *
100
+ * @since 0.3.0
101
+ */
102
+ export declare const createStyle: () => StyleBuilder;
103
+ /**
104
+ * Presets de estilo predefinidos para casos de uso comunes
105
+ *
106
+ * @constant {Object} stylePresets
107
+ *
108
+ * @example
109
+ * console.log('%cOperación exitosa', stylePresets.success);
110
+ * console.log('%cAdvertencia', stylePresets.warning);
111
+ * console.log('%cError crítico', stylePresets.error);
112
+ * console.log('%cInformación', stylePresets.info);
113
+ * console.log('%cDestacado', stylePresets.accent);
114
+ *
115
+ * @since 0.3.0
116
+ */
117
+ export declare const stylePresets: {
118
+ success: string;
119
+ error: string;
120
+ warning: string;
121
+ info: string;
122
+ accent: string;
123
+ };
124
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAER,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACd,MAAM,kBAAkB,CAAC;AAY1B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB;;;;;;;;;;;;GAYG;;AACH,wBAA2B;AAE3B;;;;;;;;;;;;GAYG;AACH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