diff --git a/src/ext/lib/ActionHandler.js b/src/ext/lib/ActionHandler.js index b63f219..3850b21 100644 --- a/src/ext/lib/ActionHandler.js +++ b/src/ext/lib/ActionHandler.js @@ -109,7 +109,7 @@ class ActionHandler { } registerHandleMouse(videoData) { - this.logger.log('info', ['actionHandler', 'mousemove'], "[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData) + this.logger.log('info', ['actionHandler', 'mousemove'], "[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData.id) var ths = this; if (videoData.player && videoData.player.element) { diff --git a/src/ext/lib/Logger.js b/src/ext/lib/Logger.js index 3efe468..72d2b2d 100644 --- a/src/ext/lib/Logger.js +++ b/src/ext/lib/Logger.js @@ -236,20 +236,22 @@ class Logger { } // exitLog overrides any other exclusions, so we look for it separately. - // we also remove some of the unnecessary messages ... except not cos - // holy fuck, the performance - let i = stackInfo.stack.trace.length; - while (i --> 0) { + // we also remove some of the unnecessary messages to reduce log file size + for(let i = 0; i < stackInfo.stack.trace.length; i++) { if (stackInfo.stack.trace[i] === 'finish') { stackInfo['exitLogs'] = true; break; } - // if (stackInfo.stack.trace[i].indexOf('promise callback') !== -1 - // || stackInfo.stack.trace[i].indexOf('asyncGeneratorStep') !== -1 - // || stackInfo.stack.trace[i].indexOf('_asyncToGenerator') !== -1 - // || stackInfo.stack.trace[i].startsWith('_next')) { - // stackInfo.stack.trace.splice(i,1); - // } + + // if we hit one of these, we remove the rest of the array and call it a + // day. Chances are there's nothing of value past this point. + if (stackInfo.stack.trace[i].indexOf('promise callback') !== -1 + || stackInfo.stack.trace[i].indexOf('asyncGeneratorStep') !== -1 + || stackInfo.stack.trace[i].indexOf('_asyncToGenerator') !== -1 + || stackInfo.stack.trace[i].startsWith('_next')) { + stackInfo.stack.trace.splice(i); + break; + } } return stackInfo; @@ -462,13 +464,27 @@ class Logger { console.info('[info] vuex store present. Parsing logs.'); - const exportObject = { - pageLogs: JSON.stringify(decycle(this.history)), - backgroundLogs: JSON.stringify(decycle(this.globalHistory)), - loggerFileOptions: JSON.stringify(this.conf.fileOptions), + let exportObject; + try { + exportObject = { + pageLogs: decycle(this.history), + backgroundLogs: decycle(this.globalHistory), + loggerFileOptions: this.conf.fileOptions, + } + } catch (e) { + console.error("[fail] error parsing logs!", e) + return; } - this.vuexStore.dispatch('uw-set-log', JSON.stringify(exportObject)); + console.info('[info] Logs were parsed successfuly. Putting stuff to vuex ...'); + try { + this.vuexStore.dispatch('uw-set-log', exportObject); + } catch (e) { + console.log("[fail] error saving to vuex", e); + return; + } + + console.info('[info] Export object saved to vuex store.') } // export log file — only works on background page diff --git a/src/ext/lib/comms/CommsClient.js b/src/ext/lib/comms/CommsClient.js index 25545ff..142c2c0 100644 --- a/src/ext/lib/comms/CommsClient.js +++ b/src/ext/lib/comms/CommsClient.js @@ -81,7 +81,7 @@ class CommsClient { this.pageInfo = pageInfo; - this.logger.log('info', 'debug', `[CommsClient::setPageInfo] <${this.commsId}>`, "SETTING PAGEINFO —", this.pageInfo, this) + this.logger.log('info', 'debug', `[CommsClient::setPageInfo] <${this.commsId}>`, "setting pageinfo"); var ths = this; this._listener = m => ths.processReceivedMessage(m); diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index 7385607..f268ddb 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -359,7 +359,7 @@ class Resizer { } restore() { - this.logger.log('info', 'debug', "[Resizer::restore] attempting to restore aspect ratio. this & settings:", {'a_lastAr': this.lastAr, 'this': this, "settings": this.settings} ); + this.logger.log('info', 'debug', "[Resizer::restore] attempting to restore aspect ratio", {'a_lastAr': this.lastAr} ); // this is true until we verify that css has actually been applied if(this.lastAr.type === AspectRatio.Initial){ @@ -462,7 +462,7 @@ class Resizer { '\nplayer dimensions: ', {w: this.conf.player.dimensions.width, h: this.conf.player.dimensions.height}, '\nvideo dimensions: ', {w: this.conf.video.offsetWidth, h: this.conf.video.offsetHeight}, '\nstretch factors: ', stretchFactors, - '\npan & zoom: ', this.pan, this.zoom, + '\npan & zoom: ', this.pan, this.zoom.scale, '\nwdiff, hdiff: ', wdiff, 'x', hdiff, '\nwdiff, hdiffAfterZoom:', wdiffAfterZoom, 'x', hdiffAfterZoom, '\n\n---- data out ----\n', diff --git a/src/ext/uw.js b/src/ext/uw.js index b17a3ae..fdbf122 100644 --- a/src/ext/uw.js +++ b/src/ext/uw.js @@ -128,17 +128,17 @@ class UW { try { this.pageInfo = new PageInfo(this.comms, this.settings, this.logger, extensionMode, isSiteDisabled); - this.logger.log('info', 'debug', "[uw.js::setup] pageInfo initialized. Here's the object:", this.pageInfo); + this.logger.log('info', 'debug', "[uw.js::setup] pageInfo initialized."); this.comms.setPageInfo(this.pageInfo); - this.logger.log('info', 'debug', "[uw.js::setup] will try to initate ActionHandler. Settings are:", this.settings, this.settings.active) + this.logger.log('info', 'debug', "[uw.js::setup] will try to initate ActionHandler."); // start action handler only if extension is enabled for this site if (!isSiteDisabled) { this.actionHandler = new ActionHandler(this.pageInfo); this.actionHandler.init(); - this.logger.log('info', 'debug', "[uw.js::setup] ActionHandler initiated:", this.actionHandler); + this.logger.log('info', 'debug', "[uw.js::setup] ActionHandler initiated."); } } catch (e) {