Skip to content

Commit

Permalink
Add logging to mobile version
Browse files Browse the repository at this point in the history
  • Loading branch information
oleeskild committed Oct 3, 2023
1 parent 1aa7c47 commit f9c1660
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
}
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit f9c1660

Please sign in to comment.