fixed logger

This commit is contained in:
Bojan Kucera 2025-06-07 09:44:17 -04:00
parent 4709887fef
commit e8485dd140
3 changed files with 48 additions and 23 deletions

View file

@ -1,7 +1,11 @@
import { proxyService, ProxySource } from './services/proxy.service.js';
import { getLogger } from '@stock-bot/logger';
// Initialize logger for the demo
const logger = getLogger('proxy-demo');
/**
* Example usage of the ProxyService
* Example usage of the ProxyService with enhanced logging
*/
// async function demonstrateProxyService() {
// console.log('🚀 Starting Proxy Service Demo...');
@ -85,10 +89,10 @@ import { proxyService, ProxySource } from './services/proxy.service.js';
// }
/**
* Example: Custom proxy source
* Example: Custom proxy source with enhanced logging
*/
async function demonstrateCustomProxySource() {
console.log('🔧 Demonstrating custom proxy source...');
logger.info('🔧 Demonstrating custom proxy source...');
const customSources : ProxySource[] = [
{
@ -96,12 +100,16 @@ async function demonstrateCustomProxySource() {
protocol: 'http'
}
];
try {
const count = await proxyService.scrapeProxies(customSources);
console.log(`✅ Scraped ${count} proxies from custom source`);
logger.info(`✅ Scraped ${count} proxies from custom source`, {
count,
sourceCount: customSources.length
});
} catch (error) {
console.error('❌ Custom source scraping failed:', error);
logger.error('❌ Custom source scraping failed', error, {
sourceUrls: customSources.map(s => s.url)
});
}
}
@ -110,7 +118,16 @@ export {
// demonstrateProxyService,
demonstrateCustomProxySource
};
// Execute the demo with enhanced logging
logger.info('🚀 Starting enhanced proxy demo...');
demonstrateCustomProxySource()
.then(() => {
logger.info('🎉 Proxy demo completed successfully!');
})
.catch((error) => {
logger.error('💥 Proxy demo failed', error);
});
// If this file is run directly, execute the demo
// if (import.meta.main) {

View file

@ -440,7 +440,6 @@ export class ProxyService {
*/
private async validateProxiesInBackground(proxies: ProxyConfig[]): Promise<void> {
this.logger.info('Starting background proxy validation', { count: proxies.length });
this.logger.error('Background validation is not implemented yet, this is a placeholder function', { error: { message: 'Background validation not implemented' } });
const concurrency = 50; // Process 50 proxies concurrently
const chunks = this.chunkArray(proxies, concurrency);