mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 08:47:43 +00:00
feat: clean up proxy logging with n/N in each lookup (#1839)
This commit is contained in:
+19
-5
@@ -241,11 +241,25 @@ function buildSetupString(
|
|||||||
|
|
||||||
function buildProductString(link: Link, store: Store, color?: boolean): string {
|
function buildProductString(link: Link, store: Store, color?: boolean): string {
|
||||||
if (color) {
|
if (color) {
|
||||||
return (
|
if (store.currentProxyIndex !== undefined && store.proxyList) {
|
||||||
chalk.cyan(`[${store.name}]`) +
|
const proxy = `${store.currentProxyIndex + 1}/${store.proxyList.length}`;
|
||||||
chalk.grey(` [${link.brand} (${link.series})] ${link.model}`)
|
return (
|
||||||
);
|
chalk.gray(`[${proxy}]`) +
|
||||||
|
chalk.cyan(` [${store.name}]`) +
|
||||||
|
chalk.grey(` [${link.brand} (${link.series})] ${link.model}`)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
chalk.cyan(`[${store.name}]`) +
|
||||||
|
chalk.grey(` [${link.brand} (${link.series})] ${link.model}`)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `[${store.name}] [${link.brand} (${link.series})] ${link.model}`;
|
if (store.currentProxyIndex !== undefined && store.proxyList) {
|
||||||
|
const proxy = `${store.currentProxyIndex + 1}/${store.proxyList.length}`;
|
||||||
|
return `[${proxy}] [${store.name}] [${link.brand} (${link.series})] ${link.model}`;
|
||||||
|
} else {
|
||||||
|
return `[${store.name}] [${link.brand} (${link.series})] ${link.model}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-8
@@ -37,15 +37,18 @@ function nextProxy(store: Store) {
|
|||||||
|
|
||||||
if (store.currentProxyIndex === undefined) {
|
if (store.currentProxyIndex === undefined) {
|
||||||
store.currentProxyIndex = 0;
|
store.currentProxyIndex = 0;
|
||||||
|
} else {
|
||||||
|
store.currentProxyIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.currentProxyIndex++;
|
|
||||||
if (store.currentProxyIndex >= store.proxyList.length) {
|
if (store.currentProxyIndex >= store.proxyList.length) {
|
||||||
store.currentProxyIndex = 0;
|
store.currentProxyIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
logger.debug(
|
||||||
`ℹ [${store.name}] Next proxy index: ${store.currentProxyIndex} / Count: ${store.proxyList.length}`
|
`ℹ [${store.name}] Next proxy index: ${store.currentProxyIndex} / Count: ${
|
||||||
|
store.proxyList.length
|
||||||
|
} (${store.proxyList[store.currentProxyIndex]})`
|
||||||
);
|
);
|
||||||
|
|
||||||
return store.proxyList[store.currentProxyIndex];
|
return store.proxyList[store.currentProxyIndex];
|
||||||
@@ -252,11 +255,22 @@ async function lookup(browser: Browser, store: Store) {
|
|||||||
try {
|
try {
|
||||||
statusCode = await lookupCard(browser, store, page, link);
|
statusCode = await lookupCard(browser, store, page, link);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error(
|
if (store.currentProxyIndex !== undefined && store.proxyList) {
|
||||||
`✖ [${store.name}] ${link.brand} ${link.series} ${link.model} - ${
|
const proxy = `${store.currentProxyIndex + 1}/${
|
||||||
(error as Error).message
|
store.proxyList.length
|
||||||
}`
|
}`;
|
||||||
);
|
logger.error(
|
||||||
|
`✖ [${proxy}] [${store.name}] ${link.brand} ${link.series} ${
|
||||||
|
link.model
|
||||||
|
} - ${(error as Error).message}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
logger.error(
|
||||||
|
`✖ [${store.name}] ${link.brand} ${link.series} ${link.model} - ${
|
||||||
|
(error as Error).message
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
const client = await page.target().createCDPSession();
|
const client = await page.target().createCDPSession();
|
||||||
await client.send('Network.clearBrowserCookies');
|
await client.send('Network.clearBrowserCookies');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user