improved logger

This commit is contained in:
Bojan Kucera 2025-06-07 10:07:49 -04:00
parent e8485dd140
commit 0f510bfa33
9 changed files with 110 additions and 1250 deletions

View file

@ -1,7 +1,7 @@
/**
* Data Service - Combined live and historical data ingestion
*/
import { createLogger, GracefulShutdownManager } from '@stock-bot/logger';
import { createLogger } from '@stock-bot/logger';
import { loadEnvVariables } from '@stock-bot/config';
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
@ -11,7 +11,6 @@ loadEnvVariables();
const app = new Hono();
const logger = createLogger('data-service');
const shutdownManager = new GracefulShutdownManager(logger);
const PORT = parseInt(process.env.DATA_SERVICE_PORT || '3002');
// Health check endpoint

View file

@ -107,7 +107,8 @@ async function demonstrateCustomProxySource() {
sourceCount: customSources.length
});
} catch (error) {
logger.error('❌ Custom source scraping failed', error, {
logger.error('❌ Custom source scraping failed',{
error: error as Error,
sourceUrls: customSources.map(s => s.url)
});
}

View file

@ -97,7 +97,7 @@ export class ProxyService {
try {
await this.scrapeProxies();
} catch (error) {
this.logger.error('Error in periodic proxy refresh', { error });
this.logger.error('Error in periodic proxy refresh', {error});
}
}, intervalMs);
}
@ -169,7 +169,7 @@ export class ProxyService {
} catch (error) {
this.logger.error('Error scraping from source', {
url: source.url,
error: error instanceof Error ? error.message : String(error)
error: error
});
return [];
}
@ -318,7 +318,7 @@ export class ProxyService {
}
}
} catch (error) {
this.logger.error('Error updating proxy status', { error });
this.logger.error('Error updating proxy status', {error});
}
}
/**
@ -346,7 +346,7 @@ export class ProxyService {
this.logger.warn('No working proxies available');
return null;
} catch (error) {
this.logger.error('Error getting working proxy', { error });
this.logger.error('Error getting working proxy', {error});
return null;
}
}
@ -371,7 +371,7 @@ export class ProxyService {
return workingProxies;
} catch (error) {
this.logger.error('Error getting working proxies', { error });
this.logger.error('Error getting working proxies', {error});
return [];
}
}
@ -391,7 +391,7 @@ export class ProxyService {
this.logger.warn('getAllProxies not fully implemented - Redis cache provider limitations');
return proxies;
} catch (error) {
this.logger.error('Error getting all proxies', { error });
this.logger.error('Error getting all proxies', {error});
return [];
}
}
@ -424,7 +424,7 @@ export class ProxyService {
return stats;
} catch (error) {
this.logger.error('Error getting proxy stats', { error });
this.logger.error('Error getting proxy stats', {error});
return {
total: 0,
working: 0,
@ -485,7 +485,7 @@ export class ProxyService {
stillWorking: successCount
});
} catch (error) {
this.logger.error('Error in health check', { error });
this.logger.error('Error in health check', {error});
}
}, intervalMs);
}
@ -502,7 +502,7 @@ export class ProxyService {
this.logger.info('Cleared proxy stats from cache');
this.logger.warn('Full proxy data clearing not implemented due to cache provider limitations');
} catch (error) {
this.logger.error('Error clearing proxy data', { error });
this.logger.error('Error clearing proxy data', {error});
}
}