Skip to content

Commit e871bd3

Browse files
authored
Merge pull request #34 from paceaux/develop
Improve the logging experience and fix screen grabs
2 parents f6c89e9 + fa5a5fe commit e871bd3

11 files changed

+4491
-12555
lines changed

cli.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@ async function main(config) {
183183
}
184184
try {
185185
const startMessage = `
186-
| Looking...
187-
| Sitemap: ${mainConfig.sitemap},
188-
| limit: ${limit === 0 ? 'None' : limit}
189-
${mainConfig.cssFile ? `| cssFile (${cssFile})` : ''}
190-
${mainConfig.selector && !mainConfig.cssFile ? `| CSS Selector (${mainConfig.selector})` : ''}
191-
${mainConfig.isSpa ? '| Handle as Single Page Application' : ''}
192-
${mainConfig.takeScreenshots ? '| Take Screenshots' : ''}
193-
${mainConfig.useExportedSitemap ? '' : '| Ignore any existing .sitemap.json file and fetch a sitemap or recrawl'}
186+
🔍🐕 SelectorHound is looking...
187+
188+
📃 Sitemap: ${mainConfig.sitemap}
189+
🛑 limit: ${limit === 0 ? 'None' : limit}
190+
${mainConfig.cssFile ? `📂 cssFile: ${cssFile}` : ''}
191+
${mainConfig.selector && !mainConfig.cssFile ? `🎯 CSS Selector: ${mainConfig.selector}` : ''}
192+
${mainConfig.showElementDetails ? '💡 Show full details for matching elements' : ''}
193+
${mainConfig.isSpa ? '💡 Handle as Single Page Application' : ''}
194+
${mainConfig.takeScreenshots ? '📷 Take Screenshots' : ''}
195+
${mainConfig.useExportedSitemap ? '' : '💡 Ignore any existing .sitemap.json file and make a new one'}
194196
`;
195197
await log
196198
.toConsole(startMessage)
@@ -209,26 +211,20 @@ ${mainConfig.useExportedSitemap ? '' : '| Ignore any existing .sitemap.json file
209211
useExportedSitemap: mainConfig.useExportedSitemap,
210212
},
211213
);
212-
await log.toConsole(`
213-
||> ${mainConfig.crawl ? 'Crawling site' : 'Fetching sitemap'}
214-
||> ${mainConfig.crawl ? 'Starting on' : 'using'} ${siteCrawler.config.startPage}
214+
log.toConsole(`
215+
🐕 ${mainConfig.crawl ? 'Crawling site' : 'Fetching sitemap'} ${mainConfig.crawl ? 'starting on 🏁' : 'from 🦴'} ${siteCrawler.config.startPage}
215216
`);
216217
await siteCrawler.produceSiteLinks();
217218

218219
const numberOfSiteLinks = siteCrawler.linkSet.size;
219-
if (!mainConfig.useExportedSitemap) {
220-
await log.toConsole(`
221-
||-> ${numberOfSiteLinks} URLs exported to ${siteCrawler.exportFileName}.sitemap.json
222-
`);
223-
} else {
224-
await log.toConsole(`
225-
||-> ${numberOfSiteLinks} URLs read from ${siteCrawler.exportFileName}.sitemap.json
226-
`);
227-
}
220+
const isNotExported = !mainConfig.useExportedSitemap;
221+
const siteLinksMessage = `🔗 ${numberOfSiteLinks} URLs ${isNotExported ? 'exported to' : 'read from'} 💾 ${siteCrawler.exportFileName}.sitemap.json`;
222+
223+
log.toConsole(siteLinksMessage);
228224

229225
if (siteCrawler.linkSet.size === 0) {
230226
const noLinksMessage = `
231-
||-> No links found. Nothing To search.`;
227+
🚫🔗 No links found. Nothing To search.`;
232228
await log
233229
.toConsole(noLinksMessage)
234230
.infoToFileAsync(noLinksMessage);
@@ -251,11 +247,13 @@ ${mainConfig.useExportedSitemap ? '' : '| Ignore any existing .sitemap.json file
251247
const { elapsedTime } = log;
252248
const friendlyTime = elapsedTime > 300 ? `${(elapsedTime / 60).toFixed(2)}m` : `${elapsedTime}s`;
253249
const endMessage = `
254-
| Finished after ${friendlyTime}
255-
| Pages Scanned: ${totalPagesSearched}
256-
| Pages with a Match: ${pagesWithSelector.length}
257-
| Total Results: ${totalMatches}
258-
| FileName: ${outputFileName}
250+
🐶 SelectorHound is finished!
251+
252+
⏱ Time lapsed: ${friendlyTime}
253+
🔗 Pages Scanned: ${totalPagesSearched}
254+
🎯 Pages with a Match: ${pagesWithSelector.length}
255+
🧮 Total Results: ${totalMatches} ${totalMatches > pagesWithSelector.length ? '(multiple matches on a page)' : ''}
256+
💾 Results File: ${outputFileName}${outputFileName !== 'pages.json' ? '.pages.json' : ''}
259257
`;
260258
await log.toConsole(endMessage, true).infoToFileAsync();
261259
} catch (mainFunctionError) {

0 commit comments

Comments
 (0)