Avoid logging too much unnecessary stuff

This commit is contained in:
Tamius Han 2020-02-03 22:13:03 +01:00
parent 8eed3431c8
commit 78364472ad
5 changed files with 38 additions and 22 deletions

View File

@ -109,7 +109,7 @@ class ActionHandler {
} }
registerHandleMouse(videoData) { 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; var ths = this;
if (videoData.player && videoData.player.element) { if (videoData.player && videoData.player.element) {

View File

@ -236,20 +236,22 @@ class Logger {
} }
// exitLog overrides any other exclusions, so we look for it separately. // exitLog overrides any other exclusions, so we look for it separately.
// we also remove some of the unnecessary messages ... except not cos // we also remove some of the unnecessary messages to reduce log file size
// holy fuck, the performance for(let i = 0; i < stackInfo.stack.trace.length; i++) {
let i = stackInfo.stack.trace.length;
while (i --> 0) {
if (stackInfo.stack.trace[i] === 'finish') { if (stackInfo.stack.trace[i] === 'finish') {
stackInfo['exitLogs'] = true; stackInfo['exitLogs'] = true;
break; break;
} }
// if (stackInfo.stack.trace[i].indexOf('promise callback') !== -1
// || stackInfo.stack.trace[i].indexOf('asyncGeneratorStep') !== -1 // if we hit one of these, we remove the rest of the array and call it a
// || stackInfo.stack.trace[i].indexOf('_asyncToGenerator') !== -1 // day. Chances are there's nothing of value past this point.
// || stackInfo.stack.trace[i].startsWith('_next')) { if (stackInfo.stack.trace[i].indexOf('promise callback') !== -1
// stackInfo.stack.trace.splice(i,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; return stackInfo;
@ -462,13 +464,27 @@ class Logger {
console.info('[info] vuex store present. Parsing logs.'); console.info('[info] vuex store present. Parsing logs.');
const exportObject = { let exportObject;
pageLogs: JSON.stringify(decycle(this.history)), try {
backgroundLogs: JSON.stringify(decycle(this.globalHistory)), exportObject = {
loggerFileOptions: JSON.stringify(this.conf.fileOptions), 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 // export log file — only works on background page

View File

@ -81,7 +81,7 @@ class CommsClient {
this.pageInfo = pageInfo; 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; var ths = this;
this._listener = m => ths.processReceivedMessage(m); this._listener = m => ths.processReceivedMessage(m);

View File

@ -359,7 +359,7 @@ class Resizer {
} }
restore() { restore() {
this.logger.log('info', 'debug', "[Resizer::restore] <rid:"+this.resizerId+"> attempting to restore aspect ratio. this & settings:", {'a_lastAr': this.lastAr, 'this': this, "settings": this.settings} ); this.logger.log('info', 'debug', "[Resizer::restore] <rid:"+this.resizerId+"> attempting to restore aspect ratio", {'a_lastAr': this.lastAr} );
// this is true until we verify that css has actually been applied // this is true until we verify that css has actually been applied
if(this.lastAr.type === AspectRatio.Initial){ 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}, '\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}, '\nvideo dimensions: ', {w: this.conf.video.offsetWidth, h: this.conf.video.offsetHeight},
'\nstretch factors: ', stretchFactors, '\nstretch factors: ', stretchFactors,
'\npan & zoom: ', this.pan, this.zoom, '\npan & zoom: ', this.pan, this.zoom.scale,
'\nwdiff, hdiff: ', wdiff, 'x', hdiff, '\nwdiff, hdiff: ', wdiff, 'x', hdiff,
'\nwdiff, hdiffAfterZoom:', wdiffAfterZoom, 'x', hdiffAfterZoom, '\nwdiff, hdiffAfterZoom:', wdiffAfterZoom, 'x', hdiffAfterZoom,
'\n\n---- data out ----\n', '\n\n---- data out ----\n',

View File

@ -128,17 +128,17 @@ class UW {
try { try {
this.pageInfo = new PageInfo(this.comms, this.settings, this.logger, extensionMode, isSiteDisabled); 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.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 // start action handler only if extension is enabled for this site
if (!isSiteDisabled) { if (!isSiteDisabled) {
this.actionHandler = new ActionHandler(this.pageInfo); this.actionHandler = new ActionHandler(this.pageInfo);
this.actionHandler.init(); 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) { } catch (e) {