diff --git a/main.ts b/main.ts index 958ae0dd..e6e4af72 100644 --- a/main.ts +++ b/main.ts @@ -76,6 +76,7 @@ export default class DigitalGarden extends Plugin { publishModal!: PublicationCenter; async onload() { + this.monkeyPatchConsole(this); this.appVersion = this.manifest.version; console.log("Initializing DigitalGarden plugin v" + this.appVersion); @@ -524,4 +525,30 @@ export default class DigitalGarden extends Plugin { } this.publishModal.open(); } + + monkeyPatchConsole(plugin: Plugin) { + if (!Platform.isMobile) { + return; + } + + const logFile = `${plugin.manifest.dir}/logs.txt`; + const logs: string[] = []; + + const logMessages = + (prefix: string) => + (...messages: unknown[]) => { + logs.push(`\n[${prefix}]`); + + for (const message of messages) { + logs.push(String(message)); + } + plugin.app.vault.adapter.write(logFile, logs.join(" ")); + }; + + console.debug = logMessages("debug"); + console.error = logMessages("error"); + console.info = logMessages("info"); + console.log = logMessages("log"); + console.warn = logMessages("warn"); + } } diff --git a/manifest-beta.json b/manifest-beta.json index e8235420..0746854d 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "digitalgarden", "name": "Digital Garden", - "version": "2.50.3", + "version": "2.50.4", "minAppVersion": "0.12.0", "description": "Publish your notes to the web for others to enjoy. For free.", "author": "Ole Eskild Steensen", diff --git a/versions.json b/versions.json index 2af90161..de851d12 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { + "2.50.4": "0.12.0", "2.50.3": "0.12.0", "2.50.2": "0.12.0", "2.50.1": "0.12.0",