diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-09-29 08:38:22 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-09-29 08:38:22 +0200 |
| commit | 87ff3970a663e2665eb3146d1224d799ca85589b (patch) | |
| tree | 3f3563398f612cc2009c63c4310faa25fe8e4b2b /html | |
| parent | cb2f9a824428448bd889f2e6df11b413cea15f40 (diff) | |
| download | muhqs-game-87ff3970a663e2665eb3146d1224d799ca85589b.tar.gz muhqs-game-87ff3970a663e2665eb3146d1224d799ca85589b.zip | |
prompt to send debug log via mail
Diffstat (limited to 'html')
| -rw-r--r-- | html/wasm.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/html/wasm.html b/html/wasm.html index a839ef6b..197836ff 100644 --- a/html/wasm.html +++ b/html/wasm.html @@ -56,6 +56,34 @@ if (!WebAssembly.instantiateStreaming) { // polyfill }; } +// Hook the console log to send debug information +// See: https://stackoverflow.com/questions/19846078/how-to-read-from-chromes-console-in-javascript#19846113 +console.oldlog = console.log.bind(console); +console.logs = []; +console.log = function(){ + console.logs.push(Array.from(arguments)); + console.oldlog.apply(console, arguments); +} + +function mailLogs() { + let mailtoLink = new URL("mailto:muhqs-game-logs@muhq.space"); + mailtoLink.searchParams.append("subject", encodeURIComponent("muhqs-game crash report")); + mailtoLink.searchParams.append("body", encodeURIComponent(console.logs)); + console.log(mailtoLink); + + if (window.confirm('Send a bug report and help to improve muhqs-game.')) { + window.open(mailtoLink, '_system'); + }; +} + +console.oldwarn = console.warn.bind(console); +console.warn = function() { + if (arguments[0] === "exit code:" && arguments[1] != 0) { + mailLogs(); + } + console.oldwarn.apply(console, arguments); +} + const go = new Go(); let mod, inst; let url = new URLSearchParams(window.location.search).get("wasm"); |
