Logger Helper eliminates the tedium of writingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pouryazardosht/nestjs-devtools/llms.txt
Use this file to discover all available pages before exploring further.
this.logger.<method>() boilerplate by hand. Select a variable or expression, press a two-key chord, and the extension inserts a fully formatted log statement on the correct line — automatically embedding the enclosing class name in the message so you always know exactly where a log came from.
How it works
Every logger insertion follows three steps drawn directly from the extension’s source:-
Read the selection. The extension reads
editor.selectionand callseditor.document.getText(selection).trim()to get the selected variable or expression. If nothing is selected, a warning is shown and execution stops. -
Detect the enclosing class name.
getEnclosingClassNamewalks upward from the cursor line, testing each line against the regex:The first match yields the class name (e.g.UserService). If no class is found, the log message omits the class prefix entirely. -
Determine the insertion point.
findInsertionLineinspects the line where the selection starts:- If that line’s trimmed text does not end with
{, the logger is inserted on the very next line. - If it does end with
{(an opening block), the algorithm counts brace depth — incrementing for every{and decrementing for every}on each subsequent line — until depth reaches0. The logger is then inserted after that closing}line, safely outside the block.
- If that line’s trimmed text does not end with
Log methods
Five methods are available, each mapped to an emoji and a dedicated keyboard chord:| Method | Emoji | macOS Chord | Windows / Linux Chord |
|---|---|---|---|
debug | 🔍 | Cmd+L Cmd+D | Ctrl+L Ctrl+D |
log | 📝 | Cmd+L Cmd+L | Ctrl+L Ctrl+L |
warn | ⚠️ | Cmd+L Cmd+W | Ctrl+L Ctrl+W |
error | ❌ | Cmd+L Cmd+E | Ctrl+L Ctrl+E |
verbose | 🔊 | Cmd+L Cmd+V | Ctrl+L Ctrl+V |
Usage example
Suppose your cursor is insideUserService and you select the identifier user after a findOne call:
"<emoji> <ClassName> ~ <selectedText>", with both the variable name and its runtime value passed to the logger.
Block-aware insertion
When the line where your selection starts ends with{, the extension skips past the entire block and places the logger after the matching closing }.
Class name detection
getEnclosingClassName scans upward from the cursor line, so it works regardless of how far down inside a class the cursor sits. The regex matches standard class declarations including exported and abstract variants:
AuthGuard, a debug statement on a selected variable token produces:
"🔍 token".
Requirements
Keyboard Shortcuts
View all logger keybindings