feat: clean up proxy logging with n/N in each lookup (#1839)

This commit is contained in:
Ben Curtis
2021-01-31 14:36:58 -05:00
committed by GitHub
parent bb8c89b775
commit 8df4339bdb
2 changed files with 41 additions and 13 deletions
+22 -8
View File
@@ -37,15 +37,18 @@ function nextProxy(store: Store) {
if (store.currentProxyIndex === undefined) {
store.currentProxyIndex = 0;
} else {
store.currentProxyIndex++;
}
store.currentProxyIndex++;
if (store.currentProxyIndex >= store.proxyList.length) {
store.currentProxyIndex = 0;
}
logger.info(
` [${store.name}] Next proxy index: ${store.currentProxyIndex} / Count: ${store.proxyList.length}`
logger.debug(
` [${store.name}] Next proxy index: ${store.currentProxyIndex} / Count: ${
store.proxyList.length
} (${store.proxyList[store.currentProxyIndex]})`
);
return store.proxyList[store.currentProxyIndex];
@@ -252,11 +255,22 @@ async function lookup(browser: Browser, store: Store) {
try {
statusCode = await lookupCard(browser, store, page, link);
} catch (error: unknown) {
logger.error(
`✖ [${store.name}] ${link.brand} ${link.series} ${link.model} - ${
(error as Error).message
}`
);
if (store.currentProxyIndex !== undefined && store.proxyList) {
const proxy = `${store.currentProxyIndex + 1}/${
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();
await client.send('Network.clearBrowserCookies');
}