diff --git a/taskRunner.js b/taskRunner.js index 44b5df9..2e4bbbb 100644 --- a/taskRunner.js +++ b/taskRunner.js @@ -14,6 +14,9 @@ var initInterval = null; var updateInterval = null; const fetchToken = () => { + console.log( + "\x1b[34mtaskRunner.js::fetchToken:", + "\x1b[0mAttempting to fetch token"); axios({ method: 'GET', url: 'http://localhost:3000/credentials' @@ -23,28 +26,43 @@ const fetchToken = () => { if (Object.keys(res.data).length == 5) { credentials = res.data; clearInterval(initInterval); - console.log("credentials received"); + console.log( + "\x1b[32mtaskRunner.js::fetchToken:", + "\x1b[0mCredentials received"); + } else { + console.log( + "\x1b[34mtaskRunner.js::fetchToken:", + "\x1b[0mAuthenticate through localhost:3000/auth") } }) .catch(err => { - console.log(err); + console.log( + "\x1b[31mtaskRunner.js::fetchToken:", + "\x1b[0mError accessing localhost:3000/credentials" + ); }); } -fetchToken(); -initInterval = setInterval(() => { +const getCredentials = () => { fetchToken(); - console.log("waiting for initial auth") -}, 10000); -updateInterval = setInterval(fetchToken, 3300 * 1000); - + initInterval = setInterval(() => { + fetchToken(); + console.log( + "\x1b[33mtaskRunner.js::getCredentials:", + "\x1b[0mWaiting for initial auth") + }, 10000); + updateInterval = setInterval(fetchToken, 3300 * 1000); +} const dispatchWatcher = () => { if (credentials == null) { - console.log("no credentials"); + console.log( + "\x1b[33mtaskRunner.js::dispatchWatcher:", + "\x1b[0mNo credentials"); } else { watcher.watch(projectID, 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA', credentials, 5); } } -setInterval(dispatchWatcher, 5000) \ No newline at end of file +getCredentials(); +setInterval(dispatchWatcher, 5000); \ No newline at end of file diff --git a/watcher.js b/watcher.js index 9233f7b..83edd36 100644 --- a/watcher.js +++ b/watcher.js @@ -32,7 +32,9 @@ exports.watch = (projectID, folderID, credentials, interval) => { }) .then(data => { if (data === undefined) { // no new files changed, return - console.log("no new files modified since " + dateXSecondsAgo.toISOString()); + console.log( + "\x1b[34mwatcher.js::watch:", + "\x1b[0mNo new files modified since " + dateXSecondsAgo.toISOString()); return; } @@ -40,7 +42,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { // console.log(data[index]); var displayName = data[index].attributes.displayName; var lastModifiedTime = data[index].attributes.lastModifiedTime; - console.log(displayName + " was modified at " + lastModifiedTime); + console.log("\x1b[34mwatcher.js::watch: \x1b[0m" + displayName + " was modified at " + lastModifiedTime); // TODO: if item is not in db, add to db and then download