Skip to content

Commit

Permalink
feat(scan): out time in log
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 25, 2020
1 parent d08787d commit ce1567c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![npm](https://img.shields.io/npm/v/site-audit-seo)](https://www.npmjs.com/package/site-audit-seo) [![npm](https://img.shields.io/npm/dt/site-audit-seo)](https://www.npmjs.com/package/site-audit-seo)

Web service and CLI tool for SEO site audit: crawl site, view public reports in browser. Also output to console, csv and xlsx.
Web service and CLI tool for SEO site audit: crawl site, lighthouse all pages, view public reports in browser. Also output to console, json, csv, xlsx, Google Drive.

Web view report - [site-audit-seo-viewer](https://viasite.github.io/site-audit-seo-viewer/).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "site-audit-seo",
"version": "4.0.0",
"description": "CLI tool for SEO site audit, crawl site, lighthouse each page, output to console, csv and xlsx",
"description": "Web service and CLI tool for SEO site audit: crawl site, lighthouse all pages, view public reports in browser. Also output to console, json, csv, xlsx, Google Drive.",
"main": "src/index.js",
"repository": {
"type": "git",
Expand Down
18 changes: 11 additions & 7 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ q.start((err) => {

const port = process.env.PORT || 5301;

function log(msg, socket) {
function log(msg, socket, outTime=false) {
if (outTime) {
msg = new Date().toTimeString().split(' ')[0] + ' ' + msg;
}
console.log(msg);
socketSend(socket, "status", msg);
}
Expand All @@ -74,7 +77,7 @@ function socketSend(socket, event, msg) {
}

io.on("connection", (socket) => {
log("user connected to server", socket);
log("user connected to server", socket, true);

submitQueueEvents(socket);

Expand All @@ -91,7 +94,7 @@ io.on("connection", (socket) => {
!socket.uid || socket.uid.includes("anon")
? "anonymous user: " + auth.uid
: "user authenticated: " + auth.email;
log(msg, socket);
log(msg, socket, true);

sendStats(socket);
});
Expand Down Expand Up @@ -121,9 +124,12 @@ io.on("connection", (socket) => {
program.outBrief(opts);

// try {
log('Pending...', socket)
log('Pending...', socket, true)
q.push(async function () {
return await scan(url, opts);
log(`Start audit: ${url}`, socket, true);
const res = await scan(url, opts);
log(`Finish audit: ${url}`, socket, true);
return res;
});
});

Expand Down Expand Up @@ -193,9 +199,7 @@ app.get("/", async (req, res) => {
});

async function scan(url, opts) {
socketSend(opts.socket, "status", `start audit: ${url}`);
const data = await scrapSite(url, opts);
socketSend(opts.socket, "status", `finish audit: ${url}`);
return data;
}

Expand Down

0 comments on commit ce1567c

Please sign in to comment.