diff --git a/src/ext/lib/Logger.js b/src/ext/lib/Logger.js index 0e2aab5..fa3513c 100644 --- a/src/ext/lib/Logger.js +++ b/src/ext/lib/Logger.js @@ -202,7 +202,7 @@ class Logger { // } else { // this.exportLogToFile(); } - this.saveToVuex(); + this.saveViaBgScript(); } parseStack() { @@ -475,6 +475,34 @@ class Logger { } } + saveViaBgScript() { + 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; + } + + Comms.sendMessage({cmd: 'show-logger', forwardToSameFramePort: true, port: 'content-ui-port'}); + + 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; + } + + try { + Comms.sendMessage({cmd: 'emit-logs', payload: JSON.stringify(exportObject), forwardToSameFramePort: true, port: 'content-ui-port'}) + } catch (e) { + console.log("failed to send message") + } + } + saveToVuex() { console.info('[info] will attempt to save to vuex store.'); if (!this.conf?.fileOptions?.enabled || this.isBackgroundScript) {