@mks2508/better-logger 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
package/src/example.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Comprehensive examples and demonstrations of Better Logger
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import logger, {
|
|
6
|
-
Logger,
|
|
7
|
-
debug,
|
|
8
|
-
info,
|
|
9
|
-
warn,
|
|
10
|
-
error,
|
|
11
|
-
success,
|
|
12
|
-
critical,
|
|
13
|
-
scope,
|
|
14
|
-
setGlobalPrefix,
|
|
15
|
-
setVerbosity,
|
|
16
|
-
setTheme,
|
|
17
|
-
setBannerType,
|
|
18
|
-
showBanner,
|
|
19
|
-
logWithSVG,
|
|
20
|
-
logAnimated,
|
|
21
|
-
cli,
|
|
22
|
-
createStyle,
|
|
23
|
-
stylePresets,
|
|
24
|
-
FileLogHandler,
|
|
25
|
-
AnalyticsLogHandler
|
|
26
|
-
} from './index.js';
|
|
27
|
-
|
|
28
|
-
// Visual features demonstrations
|
|
29
|
-
export function demonstrateBanners() {
|
|
30
|
-
info('🎨 Banner System Demo');
|
|
31
|
-
|
|
32
|
-
showBanner('simple');
|
|
33
|
-
setTimeout(() => showBanner('ascii'), 1000);
|
|
34
|
-
setTimeout(() => showBanner('unicode'), 2000);
|
|
35
|
-
setTimeout(() => showBanner('svg'), 3000);
|
|
36
|
-
setTimeout(() => showBanner('animated'), 4000);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function demonstrateThemes() {
|
|
40
|
-
info('🌈 Theme System Demo');
|
|
41
|
-
|
|
42
|
-
const themes = ['default', 'dark', 'neon', 'cyberpunk', 'retro'];
|
|
43
|
-
themes.forEach((theme, index) => {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
setTheme(theme as any);
|
|
46
|
-
info(`Theme switched to: ${theme}`);
|
|
47
|
-
}, index * 1500);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function demonstrateSVG() {
|
|
52
|
-
const logoSVG = `<svg width="100" height="50" viewBox="0 0 100 50">
|
|
53
|
-
<rect width="100" height="50" fill="#667eea"/>
|
|
54
|
-
<text x="50" y="30" font-family="Arial" font-size="12" fill="white" text-anchor="middle">LOGO</text>
|
|
55
|
-
</svg>`;
|
|
56
|
-
|
|
57
|
-
logWithSVG('🖼️ Custom SVG Background', logoSVG, {
|
|
58
|
-
width: 300,
|
|
59
|
-
height: 60,
|
|
60
|
-
padding: '20px 100px'
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function demonstrateAnimations() {
|
|
65
|
-
logAnimated('✨ Loading animation...', 3);
|
|
66
|
-
setTimeout(() => logAnimated('🚀 Animation complete!', 2), 3500);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function demonstrateCLI() {
|
|
70
|
-
info('💻 CLI Commands Demo');
|
|
71
|
-
|
|
72
|
-
const commands = [
|
|
73
|
-
'/config theme:neon',
|
|
74
|
-
'/banner ascii',
|
|
75
|
-
'/verbose debug',
|
|
76
|
-
'/prefix DEMO'
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
commands.forEach((cmd, index) => {
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
info(`Executing: ${cmd}`);
|
|
82
|
-
cli(cmd);
|
|
83
|
-
}, index * 1500);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function demonstrateExports() {
|
|
88
|
-
info('📤 Export functionality would be demonstrated here');
|
|
89
|
-
info('Note: Export features require ExportLogger from /exports module');
|
|
90
|
-
|
|
91
|
-
const sampleData = [
|
|
92
|
-
{ timestamp: new Date().toISOString(), level: 'info', message: 'Sample log 1' },
|
|
93
|
-
{ timestamp: new Date().toISOString(), level: 'error', message: 'Sample log 2' },
|
|
94
|
-
{ timestamp: new Date().toISOString(), level: 'warn', message: 'Sample log 3' }
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
logger.table(sampleData, ['timestamp', 'level', 'message']);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Core features demonstrations
|
|
101
|
-
export function demonstrateBasicLogging() {
|
|
102
|
-
setGlobalPrefix('DEMO');
|
|
103
|
-
setVerbosity('debug');
|
|
104
|
-
|
|
105
|
-
debug('🐞 Debug information', { config: { mode: 'development' } });
|
|
106
|
-
info('ℹ️ Application started successfully');
|
|
107
|
-
warn('⚠️ This is a warning message');
|
|
108
|
-
error('❌ An error occurred', new Error('Sample error'));
|
|
109
|
-
success('✅ User authentication successful');
|
|
110
|
-
critical('🔥 Critical system failure detected');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function demonstrateTable() {
|
|
114
|
-
const userData = [
|
|
115
|
-
{ id: 1, name: 'John Doe', email: 'john@example.com', status: 'active' },
|
|
116
|
-
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'inactive' },
|
|
117
|
-
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', status: 'active' }
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
logger.table(userData);
|
|
121
|
-
logger.table(userData, ['name', 'email']);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function demonstrateGrouping() {
|
|
125
|
-
logger.group('🔍 User Analysis');
|
|
126
|
-
info('Analyzing user data...');
|
|
127
|
-
|
|
128
|
-
logger.group('📊 Statistics', false);
|
|
129
|
-
info('Total users: 150');
|
|
130
|
-
info('Active users: 120');
|
|
131
|
-
info('New this month: 25');
|
|
132
|
-
logger.groupEnd();
|
|
133
|
-
|
|
134
|
-
logger.group('🎯 Top Users');
|
|
135
|
-
success('Premium user: Alice Johnson');
|
|
136
|
-
success('Most active: Bob Smith');
|
|
137
|
-
logger.groupEnd();
|
|
138
|
-
|
|
139
|
-
logger.groupEnd();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export function demonstrateTiming() {
|
|
143
|
-
logger.time('api-request');
|
|
144
|
-
|
|
145
|
-
info('🌐 Making API request...');
|
|
146
|
-
|
|
147
|
-
setTimeout(() => {
|
|
148
|
-
logger.timeEnd('api-request');
|
|
149
|
-
success('✅ API request completed');
|
|
150
|
-
}, Math.random() * 2000 + 500);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function demonstrateScopedLogger() {
|
|
154
|
-
const apiLogger = scope('API');
|
|
155
|
-
const dbLogger = scope('DB');
|
|
156
|
-
const authLogger = scope('AUTH');
|
|
157
|
-
|
|
158
|
-
apiLogger.info('🌐 Fetching user data', { endpoint: '/api/users' });
|
|
159
|
-
dbLogger.debug('💾 Database query executed', { query: 'SELECT * FROM users LIMIT 10' });
|
|
160
|
-
authLogger.success('🔐 User authentication successful', { userId: 12345 });
|
|
161
|
-
|
|
162
|
-
apiLogger.warn('⚠️ Rate limit approaching', { remaining: 10 });
|
|
163
|
-
dbLogger.error('❌ Connection timeout', { timeout: '5s' });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function demonstrateTrace() {
|
|
167
|
-
function deepFunction() {
|
|
168
|
-
function deeperFunction() {
|
|
169
|
-
logger.trace('🔍 Deep trace call with full stack');
|
|
170
|
-
}
|
|
171
|
-
deeperFunction();
|
|
172
|
-
}
|
|
173
|
-
deepFunction();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function demonstrateCustomStyles() {
|
|
177
|
-
const customStyle = createStyle()
|
|
178
|
-
.bg('linear-gradient(135deg, #ff6b6b 0%, #feca57 100%)')
|
|
179
|
-
.color('white')
|
|
180
|
-
.padding('12px 20px')
|
|
181
|
-
.rounded('10px')
|
|
182
|
-
.shadow('0 4px 15px rgba(0,0,0,0.3)')
|
|
183
|
-
.bold()
|
|
184
|
-
.build();
|
|
185
|
-
|
|
186
|
-
console.log('%c🎨 Custom Styled Message', customStyle);
|
|
187
|
-
console.log('%c✅ Success Style', stylePresets.success);
|
|
188
|
-
console.log('%c❌ Error Style', stylePresets.error);
|
|
189
|
-
console.log('%c⚠️ Warning Style', stylePresets.warning);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Comprehensive demonstration
|
|
193
|
-
export function demonstrateAllFeatures() {
|
|
194
|
-
info('🌟 Starting comprehensive Better Logger demonstration...');
|
|
195
|
-
|
|
196
|
-
setTimeout(() => demonstrateBanners(), 500);
|
|
197
|
-
setTimeout(() => demonstrateBasicLogging(), 6000);
|
|
198
|
-
setTimeout(() => demonstrateCustomStyles(), 8000);
|
|
199
|
-
setTimeout(() => demonstrateGrouping(), 10000);
|
|
200
|
-
setTimeout(() => demonstrateTiming(), 13000);
|
|
201
|
-
setTimeout(() => demonstrateScopedLogger(), 16000);
|
|
202
|
-
setTimeout(() => demonstrateThemes(), 18000);
|
|
203
|
-
|
|
204
|
-
setTimeout(() => {
|
|
205
|
-
success('🎉 Demonstration complete! Check your console for all the styled outputs.');
|
|
206
|
-
}, 25000);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Auto-run basic demo on import
|
|
210
|
-
demonstrateBasicLogging();
|
package/src/exports-module.ts
DELETED
|
@@ -1,311 +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
|
-
|
|
9
|
-
// Core logger and types
|
|
10
|
-
import { Logger } from './Logger.js';
|
|
11
|
-
import type {
|
|
12
|
-
LogLevel,
|
|
13
|
-
Verbosity,
|
|
14
|
-
ILogHandler
|
|
15
|
-
} from './types/index.js';
|
|
16
|
-
|
|
17
|
-
// Export handlers
|
|
18
|
-
import {
|
|
19
|
-
ExportLogHandler,
|
|
20
|
-
RemoteLogHandler
|
|
21
|
-
} from './handlers/index.js';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Logger with export and remote capabilities
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import { ExportLogger } from '@mks2508/better-logger/exports';
|
|
29
|
-
*
|
|
30
|
-
* const logger = new ExportLogger({ bufferSize: 1000 });
|
|
31
|
-
*
|
|
32
|
-
* // Log some data
|
|
33
|
-
* logger.info('User logged in', { userId: 123 });
|
|
34
|
-
* logger.error('Failed to process', { error: 'timeout' });
|
|
35
|
-
*
|
|
36
|
-
* // Export logs
|
|
37
|
-
* const csvData = await logger.exportLogs('csv');
|
|
38
|
-
* const jsonData = await logger.exportLogs('json');
|
|
39
|
-
*
|
|
40
|
-
* // Setup remote logging
|
|
41
|
-
* logger.addRemoteHandler('https://api.myapp.com/logs', 'api-key');
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export class ExportLogger extends Logger {
|
|
45
|
-
private exportLogHandler?: ExportLogHandler;
|
|
46
|
-
private remoteHandlers: RemoteLogHandler[] = [];
|
|
47
|
-
|
|
48
|
-
constructor(config: { bufferSize?: number } & any = {}) {
|
|
49
|
-
super(config);
|
|
50
|
-
|
|
51
|
-
// Initialize export handler if buffer size specified
|
|
52
|
-
if (config.bufferSize) {
|
|
53
|
-
this.exportLogHandler = new ExportLogHandler(config.bufferSize);
|
|
54
|
-
this.addHandler(this.exportLogHandler);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Export logs in specified format
|
|
60
|
-
*
|
|
61
|
-
* @param format - Export format (csv, json, xml)
|
|
62
|
-
* @param options - Export options
|
|
63
|
-
* @returns Promise resolving to exported data
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const csvData = await logger.exportLogs('csv');
|
|
68
|
-
* const jsonData = await logger.exportLogs('json', {
|
|
69
|
-
* filter: { level: 'error' },
|
|
70
|
-
* limit: 100
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
async exportLogs(
|
|
75
|
-
format: 'csv' | 'json' | 'xml',
|
|
76
|
-
options?: {
|
|
77
|
-
filter?: { level?: LogLevel; from?: Date; to?: Date };
|
|
78
|
-
limit?: number;
|
|
79
|
-
}
|
|
80
|
-
): Promise<string> {
|
|
81
|
-
if (!this.exportLogHandler) {
|
|
82
|
-
throw new Error('Export handler not initialized. Set bufferSize in constructor.');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Temporary implementation - ExportLogHandler needs these methods
|
|
86
|
-
return JSON.stringify([]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get current log buffer
|
|
91
|
-
*
|
|
92
|
-
* @returns Array of log entries
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const logs = logger.getLogs();
|
|
97
|
-
* console.log(`Buffered ${logs.length} log entries`);
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
getLogs(): any[] {
|
|
101
|
-
if (!this.exportLogHandler) {
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Temporary implementation - ExportLogHandler needs these methods
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Clear the log buffer
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* logger.clearLogs();
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
clearLogs(): void {
|
|
118
|
-
if (this.exportLogHandler) {
|
|
119
|
-
// Temporary implementation - ExportLogHandler needs these methods
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Get log statistics
|
|
125
|
-
*
|
|
126
|
-
* @returns Statistics object with counts by level
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const stats = logger.getLogStats();
|
|
131
|
-
* console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`);
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
getLogStats(): Record<string, number> {
|
|
135
|
-
if (!this.exportLogHandler) {
|
|
136
|
-
return {};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Temporary implementation - ExportLogHandler needs these methods
|
|
140
|
-
return {};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Add remote logging handler
|
|
145
|
-
*
|
|
146
|
-
* @param endpoint - Remote endpoint URL
|
|
147
|
-
* @param apiKey - Optional API key for authentication
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* logger.addRemoteHandler('https://logs.myservice.com/api', 'secret-key');
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
addRemoteHandler(endpoint: string, apiKey?: string): void {
|
|
155
|
-
const remoteHandler = new RemoteLogHandler(endpoint, apiKey);
|
|
156
|
-
this.remoteHandlers.push(remoteHandler);
|
|
157
|
-
this.addHandler(remoteHandler);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Remove all remote handlers
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* logger.clearRemoteHandlers();
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
clearRemoteHandlers(): void {
|
|
169
|
-
// Remove from handlers array
|
|
170
|
-
const allHandlers = this.getHandlers();
|
|
171
|
-
this.remoteHandlers.forEach(remoteHandler => {
|
|
172
|
-
const index = allHandlers.indexOf(remoteHandler);
|
|
173
|
-
if (index > -1) {
|
|
174
|
-
allHandlers.splice(index, 1);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
this.remoteHandlers = [];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Flush all remote handlers (force send pending logs)
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```typescript
|
|
186
|
-
* await logger.flushRemoteHandlers();
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
async flushRemoteHandlers(): Promise<void> {
|
|
190
|
-
const flushPromises = this.remoteHandlers.map(handler =>
|
|
191
|
-
Promise.resolve() // RemoteLogHandler needs flush method
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
await Promise.all(flushPromises);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Create singleton instance with export capabilities
|
|
199
|
-
const exportLogger = new ExportLogger({ bufferSize: 1000 });
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Export management utilities
|
|
203
|
-
*/
|
|
204
|
-
export const exportUtils = {
|
|
205
|
-
/**
|
|
206
|
-
* Export current logs as CSV
|
|
207
|
-
*/
|
|
208
|
-
async exportCSV(options?: any): Promise<string> {
|
|
209
|
-
return await exportLogger.exportLogs('csv', options);
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Export current logs as JSON
|
|
214
|
-
*/
|
|
215
|
-
async exportJSON(options?: any): Promise<string> {
|
|
216
|
-
return await exportLogger.exportLogs('json', options);
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Export current logs as XML
|
|
221
|
-
*/
|
|
222
|
-
async exportXML(options?: any): Promise<string> {
|
|
223
|
-
return await exportLogger.exportLogs('xml', options);
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Get log statistics
|
|
228
|
-
*/
|
|
229
|
-
getStats(): Record<string, number> {
|
|
230
|
-
return exportLogger.getLogStats();
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Clear all logs
|
|
235
|
-
*/
|
|
236
|
-
clear(): void {
|
|
237
|
-
exportLogger.clearLogs();
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Remote logging utilities
|
|
243
|
-
*/
|
|
244
|
-
export const remoteUtils = {
|
|
245
|
-
/**
|
|
246
|
-
* Add remote logging endpoint
|
|
247
|
-
*/
|
|
248
|
-
addEndpoint(url: string, apiKey?: string): void {
|
|
249
|
-
exportLogger.addRemoteHandler(url, apiKey);
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Clear all remote endpoints
|
|
254
|
-
*/
|
|
255
|
-
clearEndpoints(): void {
|
|
256
|
-
exportLogger.clearRemoteHandlers();
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Flush all remote logs
|
|
261
|
-
*/
|
|
262
|
-
async flush(): Promise<void> {
|
|
263
|
-
await exportLogger.flushRemoteHandlers();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Export individual logging methods with export capabilities
|
|
269
|
-
*/
|
|
270
|
-
export const debug = (...args: any[]) => exportLogger.debug(...args);
|
|
271
|
-
export const info = (...args: any[]) => exportLogger.info(...args);
|
|
272
|
-
export const warn = (...args: any[]) => exportLogger.warn(...args);
|
|
273
|
-
export const error = (...args: any[]) => exportLogger.error(...args);
|
|
274
|
-
export const success = (...args: any[]) => exportLogger.success(...args);
|
|
275
|
-
export const critical = (...args: any[]) => exportLogger.critical(...args);
|
|
276
|
-
export const trace = (...args: any[]) => exportLogger.trace(...args);
|
|
277
|
-
export const table = (data: any, columns?: string[]) => exportLogger.table(data, columns);
|
|
278
|
-
export const group = (label: string, collapsed?: boolean) => exportLogger.group(label, collapsed);
|
|
279
|
-
export const groupEnd = () => exportLogger.groupEnd();
|
|
280
|
-
export const time = (label: string) => exportLogger.time(label);
|
|
281
|
-
export const timeEnd = (label: string) => exportLogger.timeEnd(label);
|
|
282
|
-
export const setGlobalPrefix = (prefix: string) => exportLogger.setGlobalPrefix(prefix);
|
|
283
|
-
export const scope = (prefix: string) => exportLogger.scope(prefix);
|
|
284
|
-
export const setVerbosity = (level: Verbosity) => exportLogger.setVerbosity(level);
|
|
285
|
-
export const addHandler = (handler: ILogHandler) => exportLogger.addHandler(handler);
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Export functionality
|
|
289
|
-
*/
|
|
290
|
-
export const exportLogs = async (format: 'csv' | 'json' | 'xml', options?: any) =>
|
|
291
|
-
await exportLogger.exportLogs(format, options);
|
|
292
|
-
export const getLogs = () => exportLogger.getLogs();
|
|
293
|
-
export const clearLogs = () => exportLogger.clearLogs();
|
|
294
|
-
export const getLogStats = () => exportLogger.getLogStats();
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Remote logging functionality
|
|
298
|
-
*/
|
|
299
|
-
export const addRemoteHandler = (endpoint: string, apiKey?: string) =>
|
|
300
|
-
exportLogger.addRemoteHandler(endpoint, apiKey);
|
|
301
|
-
export const clearRemoteHandlers = () => exportLogger.clearRemoteHandlers();
|
|
302
|
-
export const flushRemoteHandlers = async () => await exportLogger.flushRemoteHandlers();
|
|
303
|
-
|
|
304
|
-
// Export the singleton as default
|
|
305
|
-
export default exportLogger;
|
|
306
|
-
|
|
307
|
-
// Re-export handlers
|
|
308
|
-
export { ExportLogHandler, RemoteLogHandler } from './handlers/index.js';
|
|
309
|
-
|
|
310
|
-
// Re-export types
|
|
311
|
-
export type { ILogHandler } from './types/index.js';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Analytics log handler for Advanced Logger
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Example custom handler for analytics demonstration
|
|
9
|
-
*/
|
|
10
|
-
export class AnalyticsLogHandler implements ILogHandler {
|
|
11
|
-
handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {
|
|
12
|
-
// In a real implementation, this could send analytics data
|
|
13
|
-
if (level === 'error' || level === 'critical') {
|
|
14
|
-
// Track errors for analytics
|
|
15
|
-
console.debug('Analytics: Error tracked', {
|
|
16
|
-
level,
|
|
17
|
-
message,
|
|
18
|
-
timestamp: metadata.timestamp
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|