fixed logger to output cleaner to console

This commit is contained in:
Bojan Kucera 2025-06-07 08:18:14 -04:00
parent 7eeccfe8f2
commit 9b13ac4680
4 changed files with 272 additions and 10 deletions

View file

@ -92,14 +92,14 @@ async function demonstrateCustomProxySource() {
const customSources : ProxySource[] = [
{
url: 'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks4.txt',
url: 'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt',
protocol: 'http'
}
];
try {
const count = await proxyService.scrapeProxies(customSources);
console.log(`✅ Scraped ${count} SOCKS4 proxies from custom source`);
console.log(`✅ Scraped ${count} proxies from custom source`);
} catch (error) {
console.error('❌ Custom source scraping failed:', error);
}

View file

@ -1,6 +1,6 @@
import { createLogger } from '@stock-bot/logger';
import createCache, { type CacheProvider } from '@stock-bot/cache';
import { HttpClient, ProxyConfig , RequestConfig } from '@stock-bot/http-client';
import { HttpClient, HttpClientConfig, ProxyConfig , RequestConfig } from '@stock-bot/http-client';
import type { Logger as PinoLogger } from 'pino';
export interface ProxySource {
@ -79,7 +79,6 @@ export class ProxyService {
this.httpClient = new HttpClient({
timeout: this.CHECK_TIMEOUT,
retries: 1
});
this.logger.info('ProxyService initialized');
@ -265,13 +264,11 @@ export class ProxyService {
*/
async checkProxy(proxy: ProxyConfig, checkUrl: string = this.DEFAULT_CHECK_URL): Promise<ProxyCheckResult> {
const startTime = Date.now();
try {
// Create a new HttpClient instance with the proxy
const proxyClient = new HttpClient({
timeout: this.CHECK_TIMEOUT,
retries: 0,
proxy: proxy
});