Use sendmessage instead of vuex store in logger
This commit is contained in:
parent
a629bbeab7
commit
6a3cc8e03e
@ -1,16 +1,14 @@
|
||||
import currentBrowser from '../conf/BrowserDetect';
|
||||
import { decycle } from 'json-cyclic';
|
||||
import Comms from './comms/Comms';
|
||||
|
||||
class Logger {
|
||||
constructor(options) {
|
||||
constructor() {
|
||||
this.onLogEndCallbacks = [];
|
||||
this.history = [];
|
||||
this.globalHistory = {};
|
||||
this.isContentScript = false;
|
||||
this.isBackgroundScript = true;
|
||||
|
||||
this.vuexStore = options?.vuexStore;
|
||||
this.uwInstance = options?.uwInstance;
|
||||
}
|
||||
|
||||
static saveConfig(conf) {
|
||||
@ -121,9 +119,6 @@ class Logger {
|
||||
});
|
||||
}
|
||||
|
||||
setVuexStore(store) {
|
||||
this.vuexStore = store;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.log = [];
|
||||
@ -457,6 +452,10 @@ class Logger {
|
||||
}
|
||||
}
|
||||
|
||||
appendLog(logs) {
|
||||
this.history = this.history.concat(logs);
|
||||
}
|
||||
|
||||
addLogFromPage(host, tabId, frameId, pageHistory) {
|
||||
if (! this.globalHistory[host]) {
|
||||
this.globalHistory[host] = {};
|
||||
@ -472,23 +471,13 @@ class Logger {
|
||||
}
|
||||
|
||||
saveToVuex() {
|
||||
console.info('[info] will attempt to save to vuex store.');
|
||||
console.info('[info] will attempt to save. Issuing "show-logger"');
|
||||
if (!this.conf?.fileOptions?.enabled || this.isBackgroundScript) {
|
||||
console.info('[info] Logging to file is either disabled or we\'re not on the content script. Not saving.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.vuexStore) {
|
||||
console.error("[info] No vue store.");
|
||||
if (!this.uwInstance) {
|
||||
console.error('[info] no vue instance either. Not logging.');
|
||||
return;
|
||||
}
|
||||
console.info("[info] Initializing vue and vuex instance ...");
|
||||
this.uwInstance.initVue();
|
||||
}
|
||||
|
||||
console.info('[info] vuex store present. Parsing logs.');
|
||||
Comms.sendMessage({cmd: 'show-logger', forwardToSameFramePort: true, port: 'content-ui-port'});
|
||||
|
||||
let exportObject;
|
||||
try {
|
||||
@ -502,15 +491,11 @@ class Logger {
|
||||
return;
|
||||
}
|
||||
|
||||
console.info('[info] Logs were parsed successfuly. Putting stuff to vuex ...');
|
||||
try {
|
||||
this.vuexStore.dispatch('uw-set-log', exportObject);
|
||||
Comms.sendMessage({cmd: 'emit-logs', payload: JSON.stringify(exportObject), forwardToSameFramePort: true, port: 'content-ui-port'})
|
||||
} catch (e) {
|
||||
console.log("[fail] error saving to vuex", e);
|
||||
return;
|
||||
console.log("failed to send message")
|
||||
}
|
||||
|
||||
console.info('[info] Export object saved to vuex store.')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user