Where Log
Where Log inserts console.log, console.error, console.warn, console.info, and
console.debug statements with a workspace-relative source location. Managed logs
keep their line numbers current when the file is saved.
console.log(user, '[src/pages/user.ts:42]'); // @where-log
Supported files
.js, .mjs, .cjs, .jsx
.ts, .tsx
.vue, inside <script> or <script setup> only
Insert a log
Select a single-line expression and use a shortcut. With no selection, Where Log
recognizes a simple identifier or member chain under the cursor, such as
user.profile.name, user?.profile?.name, or this.user.name. Otherwise it
inserts an empty string and places the cursor inside it.
| Method |
Windows/Linux |
macOS |
console.log |
Ctrl+Alt+L |
Cmd+Alt+L |
console.error |
Ctrl+Alt+E |
Cmd+Alt+E |
console.warn |
Ctrl+Alt+W |
Cmd+Alt+W |
console.info |
Ctrl+Alt+I |
Cmd+Alt+I |
console.debug |
Ctrl+Alt+D |
Cmd+Alt+D |
| Choose a method |
Ctrl+Alt+; |
Cmd+Alt+; |
Multiple cursors insert one log per cursor. A multi-line selection is rejected to
avoid generating ambiguous code.
Empty log completions
Type one of these tokens as the only non-whitespace content on a line, then accept
the completion with Tab or Enter:
| Token |
Output method |
wcll |
console.log |
wcle |
console.error |
wclw |
console.warn |
wcli |
console.info |
wcld |
console.debug |
Tokens inside comments, strings, or lines containing other code do not expand.
Managed logs
The // @where-log suffix marks a log as managed. On save, Where Log updates only
its location argument. It preserves the console method, user arguments, quote
style, and semicolon. Removing the marker opts that line out of future updates.
Formatter-expanded multi-line calls are supported; the stored line is the line
where console.*( starts.
Use the Command Palette for:
Where Log: Update Managed Logs
Where Log: Remove Managed Logs in Current File
Removal counts the managed logs and requires modal confirmation. Unsafe or malformed
marked code is skipped with a warning.
Settings
| Setting |
Values |
Default |
whereLog.locationPosition |
before, after |
after |
whereLog.quoteStyle |
single, double |
single |
whereLog.semicolon |
always, never |
always |
Changing locationPosition migrates existing managed logs the next time the file
is saved. Quote and semicolon settings apply only to newly inserted logs.
Paths use forward slashes and 1-based line numbers. Multi-root workspaces prefix
the workspace folder name. Files outside a workspace use a normalized absolute
path. Untitled files must be saved before insertion.
License
Licensed under AGPL-3.0-only. See LICENSE.