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 currentBrowser from '../conf/BrowserDetect';
|
||||||
import { decycle } from 'json-cyclic';
|
import { decycle } from 'json-cyclic';
|
||||||
|
import Comms from './comms/Comms';
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
constructor(options) {
|
constructor() {
|
||||||
this.onLogEndCallbacks = [];
|
this.onLogEndCallbacks = [];
|
||||||
this.history = [];
|
this.history = [];
|
||||||
this.globalHistory = {};
|
this.globalHistory = {};
|
||||||
this.isContentScript = false;
|
this.isContentScript = false;
|
||||||
this.isBackgroundScript = true;
|
this.isBackgroundScript = true;
|
||||||
|
|
||||||
this.vuexStore = options?.vuexStore;
|
|
||||||
this.uwInstance = options?.uwInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static saveConfig(conf) {
|
static saveConfig(conf) {
|
||||||
@ -121,9 +119,6 @@ class Logger {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setVuexStore(store) {
|
|
||||||
this.vuexStore = store;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.log = [];
|
this.log = [];
|
||||||
@ -457,6 +452,10 @@ class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appendLog(logs) {
|
||||||
|
this.history = this.history.concat(logs);
|
||||||
|
}
|
||||||
|
|
||||||
addLogFromPage(host, tabId, frameId, pageHistory) {
|
addLogFromPage(host, tabId, frameId, pageHistory) {
|
||||||
if (! this.globalHistory[host]) {
|
if (! this.globalHistory[host]) {
|
||||||
this.globalHistory[host] = {};
|
this.globalHistory[host] = {};
|
||||||
@ -472,23 +471,13 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveToVuex() {
|
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) {
|
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.');
|
console.info('[info] Logging to file is either disabled or we\'re not on the content script. Not saving.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.vuexStore) {
|
Comms.sendMessage({cmd: 'show-logger', forwardToSameFramePort: true, port: 'content-ui-port'});
|
||||||
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.');
|
|
||||||
|
|
||||||
let exportObject;
|
let exportObject;
|
||||||
try {
|
try {
|
||||||
@ -502,15 +491,11 @@ class Logger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('[info] Logs were parsed successfuly. Putting stuff to vuex ...');
|
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
console.log("[fail] error saving to vuex", e);
|
console.log("failed to send message")
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('[info] Export object saved to vuex store.')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user