Skip to content

Commit

Permalink
Add dump debug data button
Browse files Browse the repository at this point in the history
  • Loading branch information
ryogx committed Nov 18, 2021
1 parent 8fe531c commit 72f7c45
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src-electron/main-process/modules/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ipcMain, dialog } from "electron";
const os = require("os");
const fs = require("fs");
const path = require("path");
const archiver = require("archiver")

export class Backend {
constructor(mainWindow) {
Expand All @@ -16,6 +17,8 @@ export class Backend {
this.config_dir = null
this.config_file = null
this.config_data = {}
this.daemonFilePrefix = "ryo-daemon-out"
this.walletdFilePrefix = "ryo-walletd-out"
}

init() {
Expand Down Expand Up @@ -237,8 +240,28 @@ export class Backend {
})
}
break;
case "dump_debug_info":
let homedir = os.homedir()
let desktop = `${homedir}${path.sep}Desktop${path.sep}`
if (!fs.existsSync(desktop)) {
desktop = `${homedir}${path.sep}`
}
let dump_zip = `${desktop}ryo-wallet-dump-${new Date().toISOString().replace(/:/g,'_')}.zip`
let output = fs.createWriteStream(dump_zip);
let archive = archiver('zip');
archive.pipe(output);
let daemon = this.daemon;
let walletd = this.walletd;
let daemonFilePrefix = this.daemonFilePrefix;
let walletdFilePrefix = this.walletdFilePrefix;
archive.file(daemon.log_file, {name: `${daemonFilePrefix}.txt`})
archive.file(walletd.log_file, {name: `${walletdFilePrefix}.txt`})
archive.finalize()
this.send("dump_completed", {})
break

default:
break
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/components/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
<div>
<q-checkbox v-model="notify_empty_password" label="Notify when creating or restoring a wallet with an insecure password" />
</div>
<h6 class="q-mb-md" style="font-weight: 300">Debugging</h6>
<div>
<p>This will package the log files and other debugging information into a ZIP file.</p>
</div>
<div>
<q-btn color="primary" @click="dump" label="Dump Debug Info" />
</div>

</div>
</div>
Expand Down Expand Up @@ -117,7 +124,7 @@
</template>

<script>
import { Platform } from "quasar"
import { Platform, Loading } from "quasar"
import { mapState } from "vuex"
import SettingsGeneral from "components/settings_general"
export default {
Expand Down Expand Up @@ -235,6 +242,10 @@ export default {
this.$gateway.send("core", "save_config", this.pending_config);
this.isVisible = false
},
dump() {
Loading.show();
this.$gateway.send("core", "dump_debug_info", {});
},
showPeerDetails (entry) {
this.$q.dialog({
title: "Peer details",
Expand Down
33 changes: 33 additions & 0 deletions src/gateway/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,39 @@ export class Gateway {
}, 250);
break

case "dump_completed":
Loading.hide()
if (process.platform === "darwin") {
// Workaround for buttons not appearning on macOS
Dialog.create({
title: "Success",
message: "Debug data dumped",
ok: {
label: "OK",
color: "primary"
},
cancel: {
flat: true,
label: "",
color: this.theme=="dark"?"white":"dark"
}
}).catch(() => {
this.closeDialog = false
})
}
else {
Dialog.create({
title: "Success",
message: "Debug data dumped",
ok: {
label: "OK",
color: "primary"
}
}).catch(() => {
this.closeDialog = false
})
}
break
}
}
}

0 comments on commit 72f7c45

Please sign in to comment.