Debugging
The debug machinery itself, getDebugger, the DebugController and how namespaces are enabled, lives in @mnaoumov/typescript-lib and is described in its Debugging guide. This page covers what a plugin built on this library adds to it.
Showing debug messages in Obsidian
Section titled “Showing debug messages in Obsidian”By default, console debug messages are not shown. To enable them you have to enable Verbose mode in the console settings.

When you enable Verbose mode, you will see debug messages in the console sent via console.debug() calls.
By default, none of the debug messages are shown. You have to enable the debug namespace of the plugin explicitly. Its namespace is the plugin id, which the plugin’s README names in its Debugging section.
With Advanced Debug Mode
Section titled “With Advanced Debug Mode”The easiest route for a plugin user is the Advanced Debug Mode plugin:
- Install and enable
Advanced Debug Mode. - Either run the command
Advanced Debug Mode: Open plugin debug messages and tick the plugin in the view it opens, or runAdvanced Debug Mode: Toggle debug messages for a plugin… and pick the plugin.
Advanced Debug Mode’s settings also let you edit the debug namespaces directly.
From the console
Section titled “From the console”Without Advanced Debug Mode, open the DevTools Console (Ctrl+Shift+I, or Cmd+Option+I on macOS) and run:
window.DEBUG.enable('<plugin-id>');where <plugin-id> is the id the plugin’s README names.
More namespace patterns, for a plugin alpha-bravo:
window.DEBUG.enable('alpha-bravo'); // show all debug messages from the `alpha-bravo` pluginwindow.DEBUG.enable('alpha-bravo:obsidian-lib:*'); // show all debug messages from this library within the `alpha-bravo` pluginwindow.DEBUG.enable('alpha-bravo:*'); // show all debug messages from the `alpha-bravo` plugin and its submoduleswindow.DEBUG.enable('*:obsidian-lib:*'); // show all debug messages for this library within any pluginwindow.DEBUG.enable('*'); // show all debug messagesThe library’s own messages use the namespace obsidian-lib, such as alpha-bravo:obsidian-lib:PluginApi. So do the messages of the generic helpers that come from @mnaoumov/typescript-lib, such as the async and error helpers, because a plugin context sets that namespace for them. So alpha-bravo:obsidian-lib:* shows every library message in a plugin.
See full documentation of window.DEBUG.
To write debug messages from your plugin, call consoleDebug() on the plugin’s consoleDebugComponent. PluginBase creates that component for you and logs through it under your plugin’s id:
import { PluginBase } from '@mnaoumov/obsidian-lib/plugin/plugin';
export class AlphaBravoPlugin extends PluginBase { protected override async onloadImpl(): Promise<void> { await super.onloadImpl(); this.consoleDebugComponent.consoleDebug('alpha', 'bravo', 'charlie'); }}The member is protected, so call it from inside your plugin class.
Cancelling a runaway operation
Section titled “Cancelling a runaway operation”A vault-wide operation that turns out to be slower, or wronger, than expected can be aborted with the Advanced Debug Mode: Abort the running operation command, or from the console:
globalThis[Symbol.for('@mnaoumov/typescript-lib/state')].values.sharedAbortController.value.abort();This aborts the app-wide shared abort signal, so every operation currently observing it stops. The controller is the one getSharedAbortController() returns. Every plugin built on this library shares it, so the call cancels whichever operation is running.
The signal is replaced immediately after the abort, which means the next operation starts with a fresh one and the call above works as many times as you press it. A plain AbortController would stay aborted forever after the first call.
For this to cancel anything, the operation has to be observing that signal in the first place. From plugin code, pass it wherever an abortSignal is accepted — most usefully to loop():
import { getSharedAbortSignal } from '@mnaoumov/typescript-lib/abort-controller';import { loop } from '@mnaoumov/obsidian-lib/loop';import { PluginBase } from '@mnaoumov/obsidian-lib/plugin/plugin';
export class AlphaBravoPlugin extends PluginBase { private async processAllNotes(): Promise<void> { await loop({ abortSignal: getSharedAbortSignal(), buildNoticeMessage: ({ item, iterationString }) => `Processing ${iterationString} - ${item.path}`, items: this.app.vault.getMarkdownFiles(), pluginNoticeComponent: this.pluginNoticeComponent, processItem: async (file) => { await processFile(file); } }); }}Call getSharedAbortSignal() at the start of each operation rather than caching it, or the operation after the first abort starts already aborted.