@mks2508/better-logger 0.14.0-alpha.2 → 1.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 (205) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/dist/Logger.d.ts +12 -16
  3. package/dist/Logger.d.ts.map +1 -1
  4. package/dist/ScopedLogger.d.ts +1 -9
  5. package/dist/chunks/{Logger-D_p3xnbq.js → Logger-C9zTFYBh.js} +2 -2
  6. package/dist/chunks/Logger-C9zTFYBh.js.map +1 -0
  7. package/dist/chunks/{Logger-Crw1woqR.js → Logger-Th9SfADL.js} +50 -17
  8. package/dist/chunks/Logger-Th9SfADL.js.map +1 -0
  9. package/dist/chunks/ScopedLogger-HgV_J-ug.js +2 -0
  10. package/dist/chunks/ScopedLogger-HgV_J-ug.js.map +1 -0
  11. package/dist/chunks/ScopedLogger-uAAeJkfA.js +361 -0
  12. package/dist/chunks/ScopedLogger-uAAeJkfA.js.map +1 -0
  13. package/dist/chunks/environment-5I5unY89.js +4 -0
  14. package/dist/chunks/environment-5I5unY89.js.map +1 -0
  15. package/dist/chunks/{environment-Bxbnw4pd.js → environment-wXLQvk5g.js} +103 -11
  16. package/dist/chunks/environment-wXLQvk5g.js.map +1 -0
  17. package/dist/chunks/formatting-CiFnwe1I.js +2 -0
  18. package/dist/chunks/formatting-CiFnwe1I.js.map +1 -0
  19. package/dist/chunks/formatting-DIhpRCCk.js +380 -0
  20. package/dist/chunks/formatting-DIhpRCCk.js.map +1 -0
  21. package/dist/cli/CommandProcessor.d.ts +1 -4
  22. package/dist/cli/commands/ConfigCommand.d.ts +2 -5
  23. package/dist/cli/commands/ExportCommand.d.ts +2 -5
  24. package/dist/cli/commands/HistoryCommand.d.ts +2 -5
  25. package/dist/cli/commands/StatusCommand.d.ts +2 -5
  26. package/dist/cli/commands/ThemeCommand.d.ts +2 -5
  27. package/dist/cli/help.d.ts +2 -5
  28. package/dist/cli/index.d.ts +1 -1
  29. package/dist/constants.d.ts +110 -5
  30. package/dist/constants.d.ts.map +1 -1
  31. package/dist/core.cjs +1 -1
  32. package/dist/core.cjs.map +1 -1
  33. package/dist/core.d.ts +1 -8
  34. package/dist/core.d.ts.map +1 -1
  35. package/dist/core.js +281 -307
  36. package/dist/core.js.map +1 -1
  37. package/dist/exports-module.d.ts +1 -8
  38. package/dist/exports.cjs +1 -1
  39. package/dist/exports.js +2 -2
  40. package/dist/handlers/AnalyticsLogHandler.d.ts +1 -4
  41. package/dist/handlers/ExportLogHandler.d.ts +1 -4
  42. package/dist/handlers/ExportLogHandler.d.ts.map +1 -1
  43. package/dist/handlers/FileLogHandler.d.ts +1 -4
  44. package/dist/handlers/RemoteLogHandler.d.ts +1 -4
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.ts +8 -41
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +246 -159
  50. package/dist/index.js.map +1 -1
  51. package/dist/styling/LogStyleBuilder.d.ts +2 -5
  52. package/dist/styling/SemanticStyles.d.ts +0 -3
  53. package/dist/styling/SmartPresets.d.ts +1 -4
  54. package/dist/styling/banners.d.ts +1 -4
  55. package/dist/styling/themes.d.ts +2 -5
  56. package/dist/styling-module.d.ts +1 -8
  57. package/dist/styling.cjs +1 -1
  58. package/dist/styling.js +3 -3
  59. package/dist/types/core.d.ts +13 -0
  60. package/dist/types/core.d.ts.map +1 -1
  61. package/dist/types/handlers.d.ts +1 -4
  62. package/dist/types/index.d.ts +1 -1
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/utils/ansi-colors.d.ts +156 -0
  65. package/dist/utils/ansi-colors.d.ts.map +1 -0
  66. package/dist/utils/formatting.d.ts +20 -2
  67. package/dist/utils/formatting.d.ts.map +1 -1
  68. package/dist/utils/index.d.ts +1 -0
  69. package/dist/utils/index.d.ts.map +1 -1
  70. package/dist/utils/output.d.ts +1 -4
  71. package/dist/utils/stackTrace.d.ts +1 -4
  72. package/package.json +2 -1
  73. package/src/Logger.ts +102 -64
  74. package/src/constants.ts +131 -1
  75. package/src/core.ts +11 -7
  76. package/src/handlers/ExportLogHandler.ts +2 -1
  77. package/src/index.ts +62 -27
  78. package/src/styling/SemanticStyles.ts +1 -1
  79. package/src/types/core.ts +15 -1
  80. package/src/types/index.ts +1 -0
  81. package/src/utils/ansi-colors.ts +333 -0
  82. package/src/utils/formatting.ts +196 -6
  83. package/src/utils/index.ts +23 -11
  84. package/vite.config.ts +1 -1
  85. package/dist/.tsbuildinfo +0 -1
  86. package/dist/Logger.js +0 -1124
  87. package/dist/ScopedLogger.js +0 -426
  88. package/dist/chunks/Logger-Crw1woqR.js.map +0 -1
  89. package/dist/chunks/Logger-D_p3xnbq.js.map +0 -1
  90. package/dist/chunks/environment-Bxbnw4pd.js.map +0 -1
  91. package/dist/chunks/environment-Dm66zOML.js +0 -4
  92. package/dist/chunks/environment-Dm66zOML.js.map +0 -1
  93. package/dist/chunks/formatting-C0riPC5_.js +0 -95
  94. package/dist/chunks/formatting-C0riPC5_.js.map +0 -1
  95. package/dist/chunks/formatting-DNCAV66-.js +0 -2
  96. package/dist/chunks/formatting-DNCAV66-.js.map +0 -1
  97. package/dist/cli/CommandProcessor.js +0 -184
  98. package/dist/cli/commands/ConfigCommand.js +0 -88
  99. package/dist/cli/commands/ExportCommand.js +0 -243
  100. package/dist/cli/commands/HistoryCommand.js +0 -96
  101. package/dist/cli/commands/StatusCommand.js +0 -93
  102. package/dist/cli/commands/ThemeCommand.js +0 -79
  103. package/dist/cli/help.js +0 -118
  104. package/dist/cli/index.js +0 -46
  105. package/dist/constants.js +0 -159
  106. package/dist/example.js +0 -154
  107. package/dist/exports-module.js +0 -260
  108. package/dist/handlers/AnalyticsLogHandler.js +0 -19
  109. package/dist/handlers/ExportLogHandler.js +0 -516
  110. package/dist/handlers/FileLogHandler.js +0 -156
  111. package/dist/handlers/RemoteLogHandler.js +0 -37
  112. package/dist/handlers/index.js +0 -7
  113. package/dist/main.js +0 -139
  114. package/dist/styling/LogStyleBuilder.js +0 -289
  115. package/dist/styling/SemanticStyles.js +0 -339
  116. package/dist/styling/SmartPresets.js +0 -276
  117. package/dist/styling/StyleBuilder.js +0 -280
  118. package/dist/styling/banners.js +0 -155
  119. package/dist/styling/index.js +0 -9
  120. package/dist/styling/themes.js +0 -231
  121. package/dist/styling-module.js +0 -199
  122. package/dist/types/Logger.d.ts +0 -700
  123. package/dist/types/Logger.d.ts.map +0 -1
  124. package/dist/types/ScopedLogger.d.ts +0 -310
  125. package/dist/types/ScopedLogger.d.ts.map +0 -1
  126. package/dist/types/cli/CommandProcessor.d.ts +0 -100
  127. package/dist/types/cli/CommandProcessor.d.ts.map +0 -1
  128. package/dist/types/cli/commands/ConfigCommand.d.ts +0 -14
  129. package/dist/types/cli/commands/ConfigCommand.d.ts.map +0 -1
  130. package/dist/types/cli/commands/ExportCommand.d.ts +0 -48
  131. package/dist/types/cli/commands/ExportCommand.d.ts.map +0 -1
  132. package/dist/types/cli/commands/HistoryCommand.d.ts +0 -47
  133. package/dist/types/cli/commands/HistoryCommand.d.ts.map +0 -1
  134. package/dist/types/cli/commands/StatusCommand.d.ts +0 -30
  135. package/dist/types/cli/commands/StatusCommand.d.ts.map +0 -1
  136. package/dist/types/cli/commands/ThemeCommand.d.ts +0 -30
  137. package/dist/types/cli/commands/ThemeCommand.d.ts.map +0 -1
  138. package/dist/types/cli/help.d.ts +0 -12
  139. package/dist/types/cli/help.d.ts.map +0 -1
  140. package/dist/types/cli/index.d.ts +0 -15
  141. package/dist/types/cli/index.d.ts.map +0 -1
  142. package/dist/types/constants.d.ts +0 -119
  143. package/dist/types/constants.d.ts.map +0 -1
  144. package/dist/types/core.js +0 -28
  145. package/dist/types/example.d.ts +0 -18
  146. package/dist/types/example.d.ts.map +0 -1
  147. package/dist/types/exports-module.d.ts +0 -196
  148. package/dist/types/exports-module.d.ts.map +0 -1
  149. package/dist/types/handlers/AnalyticsLogHandler.d.ts +0 -8
  150. package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +0 -1
  151. package/dist/types/handlers/ExportLogHandler.d.ts +0 -100
  152. package/dist/types/handlers/ExportLogHandler.d.ts.map +0 -1
  153. package/dist/types/handlers/FileLogHandler.d.ts +0 -33
  154. package/dist/types/handlers/FileLogHandler.d.ts.map +0 -1
  155. package/dist/types/handlers/RemoteLogHandler.d.ts +0 -11
  156. package/dist/types/handlers/RemoteLogHandler.d.ts.map +0 -1
  157. package/dist/types/handlers/index.d.ts +0 -8
  158. package/dist/types/handlers/index.d.ts.map +0 -1
  159. package/dist/types/handlers.js +0 -4
  160. package/dist/types/index.js +0 -4
  161. package/dist/types/main.d.ts +0 -2
  162. package/dist/types/main.d.ts.map +0 -1
  163. package/dist/types/styling/LogStyleBuilder.d.ts +0 -146
  164. package/dist/types/styling/LogStyleBuilder.d.ts.map +0 -1
  165. package/dist/types/styling/SemanticStyles.d.ts +0 -178
  166. package/dist/types/styling/SemanticStyles.d.ts.map +0 -1
  167. package/dist/types/styling/SmartPresets.d.ts +0 -22
  168. package/dist/types/styling/SmartPresets.d.ts.map +0 -1
  169. package/dist/types/styling/StyleBuilder.d.ts +0 -140
  170. package/dist/types/styling/StyleBuilder.d.ts.map +0 -1
  171. package/dist/types/styling/banners.d.ts +0 -42
  172. package/dist/types/styling/banners.d.ts.map +0 -1
  173. package/dist/types/styling/index.d.ts +0 -10
  174. package/dist/types/styling/index.d.ts.map +0 -1
  175. package/dist/types/styling/themes.d.ts +0 -7
  176. package/dist/types/styling/themes.d.ts.map +0 -1
  177. package/dist/types/styling-module.d.ts +0 -178
  178. package/dist/types/styling-module.d.ts.map +0 -1
  179. package/dist/types/types/core.d.ts +0 -221
  180. package/dist/types/types/core.d.ts.map +0 -1
  181. package/dist/types/types/handlers.d.ts +0 -85
  182. package/dist/types/types/handlers.d.ts.map +0 -1
  183. package/dist/types/types/index.d.ts +0 -7
  184. package/dist/types/types/index.d.ts.map +0 -1
  185. package/dist/types/utils/environment.d.ts +0 -47
  186. package/dist/types/utils/environment.d.ts.map +0 -1
  187. package/dist/types/utils/formatting.d.ts +0 -37
  188. package/dist/types/utils/formatting.d.ts.map +0 -1
  189. package/dist/types/utils/index.d.ts +0 -7
  190. package/dist/types/utils/index.d.ts.map +0 -1
  191. package/dist/types/utils/opentui-detection.d.ts +0 -34
  192. package/dist/types/utils/opentui-detection.d.ts.map +0 -1
  193. package/dist/types/utils/output.d.ts +0 -41
  194. package/dist/types/utils/output.d.ts.map +0 -1
  195. package/dist/types/utils/stackTrace.d.ts +0 -6
  196. package/dist/types/utils/stackTrace.d.ts.map +0 -1
  197. package/dist/types/utils/timestamps.d.ts +0 -20
  198. package/dist/types/utils/timestamps.d.ts.map +0 -1
  199. package/dist/utils/environment.js +0 -85
  200. package/dist/utils/formatting.js +0 -117
  201. package/dist/utils/index.js +0 -6
  202. package/dist/utils/opentui-detection.js +0 -116
  203. package/dist/utils/output.js +0 -150
  204. package/dist/utils/stackTrace.js +0 -81
  205. package/dist/utils/timestamps.js +0 -71
package/dist/constants.js DELETED
@@ -1,159 +0,0 @@
1
- /**
2
- * @fileoverview Global constants for Advanced Logger
3
- */
4
- /**
5
- * Default configuration values
6
- */
7
- export const DEFAULT_CONFIG = {
8
- verbosity: 'info',
9
- enableColors: true,
10
- enableTimestamps: true,
11
- enableStackTrace: true,
12
- theme: 'default',
13
- bannerType: 'simple',
14
- bufferSize: 1000,
15
- autoDetectTheme: true,
16
- };
17
- /**
18
- * Basic level styles for core module (minimal CSS styling)
19
- */
20
- export const LEVEL_STYLES = {
21
- debug: {
22
- emoji: '🔍',
23
- label: 'DEBUG',
24
- background: 'linear-gradient(90deg, #6c757d, #495057)',
25
- color: '#ffffff',
26
- border: '1px solid #6c757d',
27
- shadow: '0 2px 4px rgba(108, 117, 125, 0.3)'
28
- },
29
- info: {
30
- emoji: 'ℹ️',
31
- label: 'INFO',
32
- background: 'linear-gradient(90deg, #007bff, #0056b3)',
33
- color: '#ffffff',
34
- border: '1px solid #007bff',
35
- shadow: '0 2px 4px rgba(0, 123, 255, 0.3)'
36
- },
37
- warn: {
38
- emoji: '⚠️',
39
- label: 'WARN',
40
- background: 'linear-gradient(90deg, #ffc107, #e0a800)',
41
- color: '#000000',
42
- border: '1px solid #ffc107',
43
- shadow: '0 2px 4px rgba(255, 193, 7, 0.3)'
44
- },
45
- error: {
46
- emoji: '❌',
47
- label: 'ERROR',
48
- background: 'linear-gradient(90deg, #dc3545, #c82333)',
49
- color: '#ffffff',
50
- border: '1px solid #dc3545',
51
- shadow: '0 2px 4px rgba(220, 53, 69, 0.3)'
52
- },
53
- critical: {
54
- emoji: '🚨',
55
- label: 'CRITICAL',
56
- background: 'linear-gradient(90deg, #8B0000, #FF0000)',
57
- color: '#ffffff',
58
- border: '2px solid #FF0000',
59
- shadow: '0 4px 8px rgba(255, 0, 0, 0.4)'
60
- },
61
- success: {
62
- emoji: '✅',
63
- label: 'SUCCESS',
64
- background: 'linear-gradient(90deg, #28a745, #1e7e34)',
65
- color: '#ffffff',
66
- border: '1px solid #28a745',
67
- shadow: '0 2px 4px rgba(40, 167, 69, 0.3)'
68
- }
69
- };
70
- /**
71
- * Maximum allowed buffer sizes for performance
72
- */
73
- export const BUFFER_LIMITS = {
74
- MIN_SIZE: 50,
75
- DEFAULT_SIZE: 1000,
76
- MAX_SIZE: 10000,
77
- };
78
- /**
79
- * Export format definitions with extensions
80
- */
81
- export const EXPORT_FORMATS = {
82
- json: { extension: '.json', mimeType: 'application/json' },
83
- csv: { extension: '.csv', mimeType: 'text/csv' },
84
- markdown: { extension: '.md', mimeType: 'text/markdown' },
85
- plain: { extension: '.txt', mimeType: 'text/plain' },
86
- html: { extension: '.html', mimeType: 'text/html' },
87
- };
88
- /**
89
- * CLI command definitions
90
- */
91
- export const CLI_COMMANDS = {
92
- config: 'config',
93
- help: 'help',
94
- themes: 'themes',
95
- banners: 'banners',
96
- banner: 'banner',
97
- status: 'status',
98
- reset: 'reset',
99
- demo: 'demo',
100
- export: 'export',
101
- copy: 'copy',
102
- 'buffer-size': 'buffer-size',
103
- 'clear-buffer': 'clear-buffer',
104
- 'buffer-info': 'buffer-info',
105
- };
106
- /**
107
- * Time parsing constants for relative time filters
108
- */
109
- export const TIME_UNITS = {
110
- ms: 1,
111
- s: 1000,
112
- m: 60 * 1000,
113
- h: 60 * 60 * 1000,
114
- d: 24 * 60 * 60 * 1000,
115
- };
116
- /**
117
- * Default styling values
118
- */
119
- export const STYLE_DEFAULTS = {
120
- FONT_FAMILY: 'Monaco, Consolas, monospace',
121
- FONT_SIZE: '12px',
122
- BORDER_RADIUS: '4px',
123
- PADDING: '4px 8px',
124
- };
125
- /**
126
- * Level priority mapping for filtering
127
- */
128
- export const LEVEL_PRIORITIES = {
129
- debug: 0,
130
- info: 1,
131
- warn: 2,
132
- error: 3,
133
- critical: 4,
134
- };
135
- /**
136
- * Adaptive color configurations for DevTools theme compatibility
137
- */
138
- export const ADAPTIVE_COLORS = {
139
- timestamp: {
140
- light: '#666666',
141
- dark: '#a0a0a0',
142
- },
143
- messageText: {
144
- light: '#2d3748',
145
- dark: '#f7fafc',
146
- },
147
- prefix: {
148
- light: '#2d3748',
149
- dark: '#e2e8f0',
150
- },
151
- prefixBackground: {
152
- light: '#2d3748',
153
- dark: '#4a5568',
154
- },
155
- location: {
156
- light: '#718096',
157
- dark: '#a0aec0',
158
- },
159
- };
package/dist/example.js DELETED
@@ -1,154 +0,0 @@
1
- /**
2
- * @fileoverview Comprehensive examples and demonstrations of Better Logger
3
- */
4
- import logger, { debug, info, warn, error, success, critical, scope, setGlobalPrefix, setVerbosity, setTheme, showBanner, logWithSVG, logAnimated, cli, createStyle, stylePresets } from './index.js';
5
- // Visual features demonstrations
6
- export function demonstrateBanners() {
7
- info('🎨 Banner System Demo');
8
- showBanner('simple');
9
- setTimeout(() => showBanner('ascii'), 1000);
10
- setTimeout(() => showBanner('unicode'), 2000);
11
- setTimeout(() => showBanner('svg'), 3000);
12
- setTimeout(() => showBanner('animated'), 4000);
13
- }
14
- export function demonstrateThemes() {
15
- info('🌈 Theme System Demo');
16
- const themes = ['default', 'dark', 'neon', 'cyberpunk', 'retro'];
17
- themes.forEach((theme, index) => {
18
- setTimeout(() => {
19
- setTheme(theme);
20
- info(`Theme switched to: ${theme}`);
21
- }, index * 1500);
22
- });
23
- }
24
- export function demonstrateSVG() {
25
- const logoSVG = `<svg width="100" height="50" viewBox="0 0 100 50">
26
- <rect width="100" height="50" fill="#667eea"/>
27
- <text x="50" y="30" font-family="Arial" font-size="12" fill="white" text-anchor="middle">LOGO</text>
28
- </svg>`;
29
- logWithSVG('🖼️ Custom SVG Background', logoSVG, {
30
- width: 300,
31
- height: 60,
32
- padding: '20px 100px'
33
- });
34
- }
35
- export function demonstrateAnimations() {
36
- logAnimated('✨ Loading animation...', 3);
37
- setTimeout(() => logAnimated('🚀 Animation complete!', 2), 3500);
38
- }
39
- export function demonstrateCLI() {
40
- info('💻 CLI Commands Demo');
41
- const commands = [
42
- '/config theme:neon',
43
- '/banner ascii',
44
- '/verbose debug',
45
- '/prefix DEMO'
46
- ];
47
- commands.forEach((cmd, index) => {
48
- setTimeout(() => {
49
- info(`Executing: ${cmd}`);
50
- cli(cmd);
51
- }, index * 1500);
52
- });
53
- }
54
- export function demonstrateExports() {
55
- info('📤 Export functionality would be demonstrated here');
56
- info('Note: Export features require ExportLogger from /exports module');
57
- const sampleData = [
58
- { timestamp: new Date().toISOString(), level: 'info', message: 'Sample log 1' },
59
- { timestamp: new Date().toISOString(), level: 'error', message: 'Sample log 2' },
60
- { timestamp: new Date().toISOString(), level: 'warn', message: 'Sample log 3' }
61
- ];
62
- logger.table(sampleData, ['timestamp', 'level', 'message']);
63
- }
64
- // Core features demonstrations
65
- export function demonstrateBasicLogging() {
66
- setGlobalPrefix('DEMO');
67
- setVerbosity('debug');
68
- debug('🐞 Debug information', { config: { mode: 'development' } });
69
- info('ℹ️ Application started successfully');
70
- warn('⚠️ This is a warning message');
71
- error('❌ An error occurred', new Error('Sample error'));
72
- success('✅ User authentication successful');
73
- critical('🔥 Critical system failure detected');
74
- }
75
- export function demonstrateTable() {
76
- const userData = [
77
- { id: 1, name: 'John Doe', email: 'john@example.com', status: 'active' },
78
- { id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'inactive' },
79
- { id: 3, name: 'Bob Johnson', email: 'bob@example.com', status: 'active' }
80
- ];
81
- logger.table(userData);
82
- logger.table(userData, ['name', 'email']);
83
- }
84
- export function demonstrateGrouping() {
85
- logger.group('🔍 User Analysis');
86
- info('Analyzing user data...');
87
- logger.group('📊 Statistics', false);
88
- info('Total users: 150');
89
- info('Active users: 120');
90
- info('New this month: 25');
91
- logger.groupEnd();
92
- logger.group('🎯 Top Users');
93
- success('Premium user: Alice Johnson');
94
- success('Most active: Bob Smith');
95
- logger.groupEnd();
96
- logger.groupEnd();
97
- }
98
- export function demonstrateTiming() {
99
- logger.time('api-request');
100
- info('🌐 Making API request...');
101
- setTimeout(() => {
102
- logger.timeEnd('api-request');
103
- success('✅ API request completed');
104
- }, Math.random() * 2000 + 500);
105
- }
106
- export function demonstrateScopedLogger() {
107
- const apiLogger = scope('API');
108
- const dbLogger = scope('DB');
109
- const authLogger = scope('AUTH');
110
- apiLogger.info('🌐 Fetching user data', { endpoint: '/api/users' });
111
- dbLogger.debug('💾 Database query executed', { query: 'SELECT * FROM users LIMIT 10' });
112
- authLogger.success('🔐 User authentication successful', { userId: 12345 });
113
- apiLogger.warn('⚠️ Rate limit approaching', { remaining: 10 });
114
- dbLogger.error('❌ Connection timeout', { timeout: '5s' });
115
- }
116
- export function demonstrateTrace() {
117
- function deepFunction() {
118
- function deeperFunction() {
119
- logger.trace('🔍 Deep trace call with full stack');
120
- }
121
- deeperFunction();
122
- }
123
- deepFunction();
124
- }
125
- export function demonstrateCustomStyles() {
126
- const customStyle = createStyle()
127
- .bg('linear-gradient(135deg, #ff6b6b 0%, #feca57 100%)')
128
- .color('white')
129
- .padding('12px 20px')
130
- .rounded('10px')
131
- .shadow('0 4px 15px rgba(0,0,0,0.3)')
132
- .bold()
133
- .build();
134
- console.log('%c🎨 Custom Styled Message', customStyle);
135
- console.log('%c✅ Success Style', stylePresets.success);
136
- console.log('%c❌ Error Style', stylePresets.error);
137
- console.log('%c⚠️ Warning Style', stylePresets.warning);
138
- }
139
- // Comprehensive demonstration
140
- export function demonstrateAllFeatures() {
141
- info('🌟 Starting comprehensive Better Logger demonstration...');
142
- setTimeout(() => demonstrateBanners(), 500);
143
- setTimeout(() => demonstrateBasicLogging(), 6000);
144
- setTimeout(() => demonstrateCustomStyles(), 8000);
145
- setTimeout(() => demonstrateGrouping(), 10000);
146
- setTimeout(() => demonstrateTiming(), 13000);
147
- setTimeout(() => demonstrateScopedLogger(), 16000);
148
- setTimeout(() => demonstrateThemes(), 18000);
149
- setTimeout(() => {
150
- success('🎉 Demonstration complete! Check your console for all the styled outputs.');
151
- }, 25000);
152
- }
153
- // Auto-run basic demo on import
154
- demonstrateBasicLogging();
@@ -1,260 +0,0 @@
1
- /**
2
- * @fileoverview Exports Module - Export and remote logging capabilities
3
- * @version 0.0.1
4
- *
5
- * This module provides export functionality for logs including CSV, JSON, XML formats
6
- * and remote logging capabilities for sending logs to external services.
7
- */
8
- // Core logger and types
9
- import { Logger } from './Logger.js';
10
- // Export handlers
11
- import { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';
12
- /**
13
- * Logger with export and remote capabilities
14
- *
15
- * @example
16
- * ```typescript
17
- * import { ExportLogger } from '@mks2508/better-logger/exports';
18
- *
19
- * const logger = new ExportLogger({ bufferSize: 1000 });
20
- *
21
- * // Log some data
22
- * logger.info('User logged in', { userId: 123 });
23
- * logger.error('Failed to process', { error: 'timeout' });
24
- *
25
- * // Export logs
26
- * const csvData = await logger.exportLogs('csv');
27
- * const jsonData = await logger.exportLogs('json');
28
- *
29
- * // Setup remote logging
30
- * logger.addRemoteHandler('https://api.myapp.com/logs', 'api-key');
31
- * ```
32
- */
33
- export class ExportLogger extends Logger {
34
- exportLogHandler;
35
- remoteHandlers = [];
36
- constructor(config = {}) {
37
- super(config);
38
- // Initialize export handler if buffer size specified
39
- if (config.bufferSize) {
40
- this.exportLogHandler = new ExportLogHandler(config.bufferSize);
41
- this.addHandler(this.exportLogHandler);
42
- }
43
- }
44
- /**
45
- * Export logs in specified format
46
- *
47
- * @param format - Export format (csv, json, xml)
48
- * @param options - Export options
49
- * @returns Promise resolving to exported data
50
- *
51
- * @example
52
- * ```typescript
53
- * const csvData = await logger.exportLogs('csv');
54
- * const jsonData = await logger.exportLogs('json', {
55
- * filter: { level: 'error' },
56
- * limit: 100
57
- * });
58
- * ```
59
- */
60
- async exportLogs(format, options) {
61
- if (!this.exportLogHandler) {
62
- throw new Error('Export handler not initialized. Set bufferSize in constructor.');
63
- }
64
- // Temporary implementation - ExportLogHandler needs these methods
65
- return JSON.stringify([]);
66
- }
67
- /**
68
- * Get current log buffer
69
- *
70
- * @returns Array of log entries
71
- *
72
- * @example
73
- * ```typescript
74
- * const logs = logger.getLogs();
75
- * console.log(`Buffered ${logs.length} log entries`);
76
- * ```
77
- */
78
- getLogs() {
79
- if (!this.exportLogHandler) {
80
- return [];
81
- }
82
- // Temporary implementation - ExportLogHandler needs these methods
83
- return [];
84
- }
85
- /**
86
- * Clear the log buffer
87
- *
88
- * @example
89
- * ```typescript
90
- * logger.clearLogs();
91
- * ```
92
- */
93
- clearLogs() {
94
- if (this.exportLogHandler) {
95
- // Temporary implementation - ExportLogHandler needs these methods
96
- }
97
- }
98
- /**
99
- * Get log statistics
100
- *
101
- * @returns Statistics object with counts by level
102
- *
103
- * @example
104
- * ```typescript
105
- * const stats = logger.getLogStats();
106
- * console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);
107
- * ```
108
- */
109
- getLogStats() {
110
- if (!this.exportLogHandler) {
111
- return {};
112
- }
113
- // Temporary implementation - ExportLogHandler needs these methods
114
- return {};
115
- }
116
- /**
117
- * Add remote logging handler
118
- *
119
- * @param endpoint - Remote endpoint URL
120
- * @param apiKey - Optional API key for authentication
121
- *
122
- * @example
123
- * ```typescript
124
- * logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');
125
- * ```
126
- */
127
- addRemoteHandler(endpoint, apiKey) {
128
- const remoteHandler = new RemoteLogHandler(endpoint, apiKey);
129
- this.remoteHandlers.push(remoteHandler);
130
- this.addHandler(remoteHandler);
131
- }
132
- /**
133
- * Remove all remote handlers
134
- *
135
- * @example
136
- * ```typescript
137
- * logger.clearRemoteHandlers();
138
- * ```
139
- */
140
- clearRemoteHandlers() {
141
- // Remove from handlers array
142
- const allHandlers = this.getHandlers();
143
- this.remoteHandlers.forEach(remoteHandler => {
144
- const index = allHandlers.indexOf(remoteHandler);
145
- if (index > -1) {
146
- allHandlers.splice(index, 1);
147
- }
148
- });
149
- this.remoteHandlers = [];
150
- }
151
- /**
152
- * Flush all remote handlers (force send pending logs)
153
- *
154
- * @example
155
- * ```typescript
156
- * await logger.flushRemoteHandlers();
157
- * ```
158
- */
159
- async flushRemoteHandlers() {
160
- const flushPromises = this.remoteHandlers.map(handler => Promise.resolve() // RemoteLogHandler needs flush method
161
- );
162
- await Promise.all(flushPromises);
163
- }
164
- }
165
- // Create singleton instance with export capabilities
166
- const exportLogger = new ExportLogger({ bufferSize: 1000 });
167
- /**
168
- * Export management utilities
169
- */
170
- export const exportUtils = {
171
- /**
172
- * Export current logs as CSV
173
- */
174
- async exportCSV(options) {
175
- return await exportLogger.exportLogs('csv', options);
176
- },
177
- /**
178
- * Export current logs as JSON
179
- */
180
- async exportJSON(options) {
181
- return await exportLogger.exportLogs('json', options);
182
- },
183
- /**
184
- * Export current logs as XML
185
- */
186
- async exportXML(options) {
187
- return await exportLogger.exportLogs('xml', options);
188
- },
189
- /**
190
- * Get log statistics
191
- */
192
- getStats() {
193
- return exportLogger.getLogStats();
194
- },
195
- /**
196
- * Clear all logs
197
- */
198
- clear() {
199
- exportLogger.clearLogs();
200
- }
201
- };
202
- /**
203
- * Remote logging utilities
204
- */
205
- export const remoteUtils = {
206
- /**
207
- * Add remote logging endpoint
208
- */
209
- addEndpoint(url, apiKey) {
210
- exportLogger.addRemoteHandler(url, apiKey);
211
- },
212
- /**
213
- * Clear all remote endpoints
214
- */
215
- clearEndpoints() {
216
- exportLogger.clearRemoteHandlers();
217
- },
218
- /**
219
- * Flush all remote logs
220
- */
221
- async flush() {
222
- await exportLogger.flushRemoteHandlers();
223
- }
224
- };
225
- /**
226
- * Export individual logging methods with export capabilities
227
- */
228
- export const debug = (...args) => exportLogger.debug(...args);
229
- export const info = (...args) => exportLogger.info(...args);
230
- export const warn = (...args) => exportLogger.warn(...args);
231
- export const error = (...args) => exportLogger.error(...args);
232
- export const success = (...args) => exportLogger.success(...args);
233
- export const critical = (...args) => exportLogger.critical(...args);
234
- export const trace = (...args) => exportLogger.trace(...args);
235
- export const table = (data, columns) => exportLogger.table(data, columns);
236
- export const group = (label, collapsed) => exportLogger.group(label, collapsed);
237
- export const groupEnd = () => exportLogger.groupEnd();
238
- export const time = (label) => exportLogger.time(label);
239
- export const timeEnd = (label) => exportLogger.timeEnd(label);
240
- export const setGlobalPrefix = (prefix) => exportLogger.setGlobalPrefix(prefix);
241
- export const scope = (prefix) => exportLogger.scope(prefix);
242
- export const setVerbosity = (level) => exportLogger.setVerbosity(level);
243
- export const addHandler = (handler) => exportLogger.addHandler(handler);
244
- /**
245
- * Export functionality
246
- */
247
- export const exportLogs = async (format, options) => await exportLogger.exportLogs(format, options);
248
- export const getLogs = () => exportLogger.getLogs();
249
- export const clearLogs = () => exportLogger.clearLogs();
250
- export const getLogStats = () => exportLogger.getLogStats();
251
- /**
252
- * Remote logging functionality
253
- */
254
- export const addRemoteHandler = (endpoint, apiKey) => exportLogger.addRemoteHandler(endpoint, apiKey);
255
- export const clearRemoteHandlers = () => exportLogger.clearRemoteHandlers();
256
- export const flushRemoteHandlers = async () => await exportLogger.flushRemoteHandlers();
257
- // Export the singleton as default
258
- export default exportLogger;
259
- // Re-export handlers
260
- export { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';
@@ -1,19 +0,0 @@
1
- /**
2
- * @fileoverview Analytics log handler for Advanced Logger
3
- */
4
- /**
5
- * Example custom handler for analytics demonstration
6
- */
7
- export class AnalyticsLogHandler {
8
- handle(level, message, _args, metadata) {
9
- // In a real implementation, this could send analytics data
10
- if (level === 'error' || level === 'critical') {
11
- // Track errors for analytics
12
- console.debug('Analytics: Error tracked', {
13
- level,
14
- message,
15
- timestamp: metadata.timestamp
16
- });
17
- }
18
- }
19
- }