iToverDose/Software· 3 JUNE 2026 · 08:01

Log Stripper: Clean VS Code debug logs in 23+ languages safely

Tired of manually deleting console.log statements before pull requests? Discover a VS Code extension that automates log cleanup across 23+ languages with safe previews and workspace-wide support.

DEV Community3 min read0 Comments

Every developer knows the sinking feeling when a last-minute scan exposes forgotten debug logs before a pull request. Those console.log statements that slipped through testing now clutter your commit history, only to be discovered weeks later in production logs. Saurabh Choudhary faced this frustration repeatedly across JavaScript, Python, Go, and other codebases until he built a solution that works exactly as needed.

That solution is Log Stripper, a VS Code extension that removes debugging statements safely across 23+ languages with two essential features: a preview mode that shows what will be deleted before any changes occur, and a highlight mode that marks debug lines for manual review. The extension handles everything from simple print() statements to complex multi-line JavaScript console calls while preserving commented-out code and inline logging expressions.

How Log Stripper Works in VS Code

Log Stripper integrates seamlessly into the VS Code workflow through multiple entry points. The preview mode (Ctrl+Shift+D) scans the current file and displays every debug statement that would be removed, allowing you to approve or reject each change before execution. The highlight mode (Ctrl+Shift+H) simply marks these lines in red without modifying the file, giving you time to review without committing to deletions.

For team environments, the workspace cleanup feature removes debug statements from entire projects in a single command, making it ideal for pre-release housekeeping. The extension also provides context menu options for quick access and editor toolbar icons for immediate visibility of debug log status.

Language Support and Technical Implementation

Log Stripper supports over 23 programming languages including JavaScript, TypeScript, Python, Java, Go, Rust, C#, Swift, Kotlin, Dart, Ruby, PHP, C, C++, Shell, Lua, Scala, Elixir, Haskell, R, Vue, Svelte, and JSX/TSX. Each language's debug patterns are handled appropriately:

  • JavaScript/TypeScript: console.log, console.debug, debugger
  • Python: print(), logging.debug(), breakpoint()
  • Java: System.out.println, logger.debug()
  • Go: fmt.Println, log.Fatal
  • Rust: println!, dbg!, eprintln!
  • C#: Console.WriteLine, Debug.Write
  • Swift: print(), NSLog()
  • Ruby: puts, binding.pry
  • PHP: var_dump(), dd()
  • Shell: echo, printf

The technical challenge lies in properly identifying and removing complex multi-line debug statements. For example, the extension must correctly parse expressions like:

console.log(
  "user:", JSON.stringify(user, null, 2),
  "role:", user.role
);

This requires tracking parentheses depth while ignoring those inside string literals, handling escape sequences, and identifying the exact closing parenthesis and semicolon. The core algorithm maintains a balance counter that increments for each opening parenthesis and decrements for each closing one, while carefully tracking string delimiters to avoid miscounting nested parentheses inside strings.

Safety Design and Testing Approach

Safety is paramount in Log Stripper's design. The extension will never remove debug statements that appear in comments, inline code expressions, or conditional statements. Only whole debug calls occupying entire lines (after indentation) are targeted for removal. This prevents accidental deletion of important logging infrastructure while effectively cleaning up development artifacts.

The implementation follows a clean architecture pattern with a strict separation between core logic and VS Code integration. The stripper.ts file contains pure parsing and removal logic that can be tested independently without launching the VS Code host environment:

node --test out-test/test/stripper.test.js

This 151-test suite runs quickly without complex mocking, ensuring the parsing logic remains robust across different debug statement formats and language-specific variations.

Installation and Practical Usage

Installing Log Stripper takes seconds through either the VS Code Marketplace or the built-in extensions panel. Once installed, you can access the extension through:

  • The command palette (Ctrl+Shift+P) with commands like "Log Stripper: Preview & Strip Current File"
  • Right-click context menu options for quick file-specific operations
  • Editor toolbar icons that indicate debug log presence and status

Typical usage involves opening a file with debug statements, triggering the preview mode to review all identified logs, confirming the deletions, and then proceeding with your pull request confident that production environments won't be polluted with development artifacts.

This weekend project solved a universal developer frustration by addressing both the technical challenge of multi-language debug statement parsing and the practical need for safe, preview-driven workflows. Try it and reclaim those minutes spent manually cleaning up before every commit.

AI summary

Remove debug statements automatically in VS Code with Log Stripper's safe preview mode across JavaScript, Python, Go and 20+ languages before PRs.

Comments

00
LEAVE A COMMENT
ID #A5YDRA

0 / 1200 CHARACTERS

Human check

9 + 7 = ?

Will appear after editor review

Moderation · Spam protection active

No approved comments yet. Be first.