diff --git a/README.md b/README.md index 65bb644..ddf712b 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,95 @@ This is a plugin for [Obsidian](https://obsidian.md/) that enhances Obsidian debug mode. -## Installation +## Features -- The plugin is not available in [the official Community Plugins repository](https://obsidian.md/plugins) yet. -- [Beta releases](obsidian://brat?plugin=https://github.com/mnaoumov/obsidian-advanced-debug-mode) can be installed via [BRAT](https://obsidian.md/plugins?id=obsidian42-brat). +### Obsidian Debug mode -## Debugging +The plugin adds an easy way to switch Obsidian debug mode on/off. This helps with trimmed sourcemaps. -By default, debug messages for this plugin are hidden. +### Long stack traces -To show them, run the following command: +Error stack traces are usually very limited and stack frames for function like `setTimeout` or `addEventListener` are usually not included, so sometimes it's difficult to find the root cause of the error. + +The plugin tries to preserve long stack traces as much as possible. + +For example, ```js -window.DEBUG.enable('advanced-debug-mode'); +function foo() { + bar(); +} + +function bar() { + setTimeout(baz, 100); +} + +function baz() { + qux(); +} + +function qux() { + throw new Error('Error from qux'); +} + +foo(); ``` +Without the plugin you get the error in the console + +``` +Uncaught Error: Error from qux + at qux (:14:9) + at baz (:10:3) +``` + +With the plugin you get + +``` +Uncaught Error: Error from qux + at qux (:14:9) + at baz (:10:3) + at --- setTimeout --- (0) + at bar (:6:3) + at foo (:2:3) + at :1:1 +``` + +> [!WARNING] +> +> The plugin does not provide long stack traces for `async/await` functions. It seems to be impossible to do accurately due to the JavaScript engine limitations. + +### DevTools for mobile app + +The plugin adds DevTools for the mobile app. This helps to debug the plugins without connecting mobile to the desktop. + +![DevTools](images/devtools.jpg) + +### Debug namespaces management + +Some plugins use [debug](https://github.com/debug-js/debug) library to conditionally show/hide `console.debug` messages. + +The plugin adds an ability to manage those debug namespaces from the UI. + For more details, refer to the [documentation](https://github.com/mnaoumov/obsidian-dev-utils?tab=readme-ov-file#debugging). +## Installation + +The plugin is not available in [the official Community Plugins repository](https://obsidian.md/plugins) yet. + +### Beta versions + +To install the latest beta release of this plugin (regardless if it is available in [the official Community Plugins repository](https://obsidian.md/plugins) or not), follow these steps: + +1. Make sure to have the [BRAT plugin](https://obsidian.md/plugins?id=obsidian42-brat) installed and enabled. +2. Paste the following link in your browser and press `Enter`: + + ``` + obsidian://brat?plugin=https://github.com/mnaoumov/obsidian-advanced-debug-mode + ``` + +3. An Obsidian pop-up window should appear. In the window, click the `Add plugin` button once and wait a few seconds for the plugin to install. + ## Support Buy Me A Coffee diff --git a/images/devtools.jpg b/images/devtools.jpg new file mode 100644 index 0000000..86189ff Binary files /dev/null and b/images/devtools.jpg differ