Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>LogBroom - Pre-Commit Debug CleanerNew to Visual Studio Code? Get it now.
LogBroom - Pre-Commit Debug Cleaner

LogBroom - Pre-Commit Debug Cleaner

Harsh Joshi

|
25 installs
| (0) | Free
Sweep away debug logs before they ship. Automatically detect and remove debug logs from staged files before commit.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

LogBroom - Pre-Commit Debug Log Cleaner

Sweep away debug logs before they ship to production

Never commit debug logs to production again. LogBroom scans your git-staged files for debug logs using customizable patterns and offers to remove them before you commit.

The Problem

You add console.log('🐛 user:', user) while debugging. Hours later, you commit your changes. The debug log ships to production. Your monitoring fills with noise. Sound familiar?

The Solution

LogBroom integrates with your git workflow to catch debug logs before they're committed. Define patterns that match your debug style, and LogBroom will scan staged files and help you clean them up.

Features

  • ✅ Git-Aware Scanning - Only scans staged files (what you're about to commit)
  • ✅ Customizable Patterns - Define regex patterns matching your debug style
  • ✅ 16 Built-in Patterns - Works out of the box for common debug styles
  • ✅ Safe Removal - Preserves other logs, only removes what matches
  • ✅ Visual Feedback - Status bar integration and editor decorations
  • ✅ Team-Shareable - Export/import patterns to standardize across your team
  • ✅ Multi-Language - Supports JS, TS, Python, Go, Rust, and more

Quick Start

1. Install the Extension

Search for "LogBroom" in VSCode Extensions marketplace, or install from CLI:

code --install-extension josharsh.logbroom

2. Stage Your Files

git add .

3. Scan for Debug Logs

Press Cmd+Shift+L (Mac) or Ctrl+Shift+L (Windows/Linux), or run:

LogBroom: Scan Staged Files for Debug Logs

4. Remove Debug Logs

LogBroom will show you what it found. Choose:

  • Remove All - Clean everything in one click
  • Review Each - Manually review each match
  • Preview Changes - See a diff before removing
  • Ignore - Keep the logs this time

5. Commit Clean Code

git commit -m "Add user authentication"

Your commit is now free of debug logs!

Built-in Patterns

LogBroom comes with 16 pre-configured patterns:

JavaScript/TypeScript

Pattern Example Enabled by Default
🐛 Emoji Bug Logs console.log('🐛 user:', user) ✅
🔥 Emoji Fire Logs console.log('🔥 hot path') ✅
👀 Emoji Eyes Logs console.log('👀 watching:', x) ✅
DEBUG Prefix console.log('DEBUG:', data) ✅
TMP/XXX Markers console.log('XXX check this') ✅
Commented Logs // console.log('test') ✅
Commented Debugger // debugger ✅
Triple Slash console.log('/// debug') ❌
TODO Logs console.log('TODO: remove') ❌
console.dir console.dir(object) ❌
console.table console.table(data) ❌
console.trace console.trace() ❌

Python

Pattern Example Enabled by Default
DEBUG Prints print("DEBUG:", data) ✅
Commented Prints # print(data) ✅

Go

Pattern Example Enabled by Default
DEBUG Println fmt.Println("DEBUG:", data) ✅

Rust

Pattern Example Enabled by Default
DEBUG Println println!("DEBUG: {:?}", data) ✅

Custom Patterns

Create patterns matching your debug style:

Add a Pattern

  1. Open Command Palette (Cmd+Shift+P)
  2. Run: LogBroom: Manage Debug Patterns
  3. Select Add New Pattern
  4. Enter:
    • Name: "My Debug Style"
    • Pattern: console\.log\(['"]>>>
    • Description: "Matches logs with >>> prefix"

Pattern Examples

# Match specific emoji
console\.log\(['"](https://github.com/josharsh/logbroom/blob/HEAD/🚀|💥|⚡)

# Match custom prefix
console\.log\(['"]MY-APP:

# Match all console.warn
^\\s*console\\.warn\\(

# Match Python debug with emoji
^\\s*print\\(['"](https://github.com/josharsh/logbroom/blob/HEAD/🐛|DEBUG)

# Match Go debug with custom prefix
fmt\\.Println\\("\\[DBG\\]

Test Your Pattern

  1. Open the file you want to test
  2. Run: LogBroom: Test Pattern Against Current File
  3. Enter your pattern
  4. See how many matches it finds

Team Configuration

Share patterns with your team by committing a config file:

Create .vscode/logbroom.json

{
  "version": "1.0",
  "patterns": [
    {
      "id": "team-debug",
      "name": "Team Debug Style",
      "pattern": "console\\.log\\(['\"]\\[DEBUG\\]",
      "description": "Our team's standardized debug logs",
      "enabled": true,
      "examples": [
        "console.log('[DEBUG] user:', user)"
      ]
    }
  ],
  "exclude": [
    "src/logger/**",
    "src/monitoring/**"
  ]
}

Export/Import Patterns

Export:

  1. Run: LogBroom: Manage Debug Patterns
  2. Select: Import/Export Patterns → Export Patterns to JSON
  3. Share the JSON file with your team

Import:

  1. Run: LogBroom: Manage Debug Patterns
  2. Select: Import/Export Patterns → Import Patterns from JSON
  3. Select the JSON file

Configuration

Settings

{
  // Custom patterns (in addition to built-in)
  "logbroom.patterns": [],

  // Auto-scan staged files when saving
  "logbroom.autoScanOnCommit": true,

  // Show notifications when logs found
  "logbroom.showNotifications": true,

  // Highlight matched logs in editor
  "logbroom.highlightInEditor": true,

  // Show status bar item
  "logbroom.statusBarEnabled": true,

  // File types to scan
  "logbroom.fileTypes": [
    ".js", ".ts", ".jsx", ".tsx",
    ".py", ".go", ".rs", ".java",
    ".rb", ".cs", ".php", ".cpp"
  ],

  // Paths to exclude from scanning
  "logbroom.excludePaths": [
    "node_modules/",
    "dist/",
    "build/",
    ".git/"
  ],

  // Files to never clean (whitelist)
  "logbroom.whitelist": [
    "src/logger/index.ts",
    "src/monitoring/**"
  ]
}

Commands

Command Keybinding Description
LogBroom: Scan Staged Files Cmd+Shift+L Scan git-staged files for debug logs
LogBroom: Clean Staged Files - Remove all debug logs from staged files
LogBroom: Scan Current File Cmd+Alt+L Scan only the active editor file
LogBroom: Manage Debug Patterns - Add, edit, or toggle debug patterns
LogBroom: Test Pattern - Test a regex pattern against current file
LogBroom: Show Statistics - View debug log cleanup statistics

Status Bar

The status bar shows the current state:

Icon Meaning
$(pass) LogBroom No debug logs in staged files ✅
$(warning) 3 debug logs Found some debug logs (click to scan)
$(alert) 15 debug logs! Many debug logs found!
$(sync~spin) Scanning... Currently scanning
$(question) LogBroom Not a git repository

Click the status bar item to trigger a scan.

Use Cases

Before Every Commit

Make it a habit to scan before committing:

git add .
# Press Cmd+Shift+L to scan
# Review and remove debug logs
git commit -m "Your message"

Code Review Safety Net

Even if you forget, reviewers can catch debug logs by running LogBroom on the PR branch.

Team Onboarding

New team members automatically get your debug patterns when they open the workspace.

CI/CD Integration

(Coming soon) Fail builds if debug logs are detected in commits.

How It Works

1. Git Integration

LogBroom uses git diff --staged to get the list of staged files and git show :path to read the staged content (what's in the index, not your working directory).

2. Pattern Matching

Each enabled pattern is tested against each line of each staged file using JavaScript's RegExp.

3. Safe Removal

When you choose to remove logs:

  • Files are read from the working directory
  • Lines matching the exact content from the scan are removed
  • Files are saved and re-staged automatically
  • If a line changed since the scan, it's skipped (safety check)

4. No External Dependencies

LogBroom uses only:

  • VSCode API
  • Node.js built-ins (child_process, fs, path, util)
  • Git (already on your system)

FAQ

Q: Will this remove my legitimate logs?

A: No. LogBroom only matches patterns you define. Production logs like logger.info() or console.error() won't match debug patterns. You have full control over what gets removed.

Q: What if I forget to run it?

A: Enable autoScanOnCommit to get notified when you save staged files. The status bar also shows a warning if debug logs are present.

Q: Can I use this with other languages?

A: Yes! Add custom patterns for any language. Built-in patterns support JS, TS, Python, Go, Rust, Java, Ruby, C#, PHP, and C++.

Q: Will this modify files I haven't staged?

A: No. LogBroom only scans and modifies staged files. Your working directory changes are safe.

Q: Can I exclude certain files?

A: Yes. Use logbroom.excludePaths for directories and logbroom.whitelist for specific files.

Q: Does this work with monorepos?

A: Yes. LogBroom works at the git repository level, whether you have one project or many.

Troubleshooting

No matches found but I see debug logs

  1. Check if the file is staged: git status
  2. Check if your pattern is enabled: LogBroom: Manage Debug Patterns
  3. Test your pattern: LogBroom: Test Pattern Against Current File
  4. Check file type is in logbroom.fileTypes setting

"Not a git repository" error

LogBroom requires a git repository. Initialize one:

git init

Patterns not working after update

Try reloading VSCode:

Developer: Reload Window

Roadmap

  • [ ] Git hook installation (automatic pre-commit checks)
  • [ ] Statistics dashboard (track cleanup history)
  • [ ] Pattern suggestions (learn from your code)
  • [ ] CI/CD integration (fail builds with debug logs)
  • [ ] Team analytics (most common patterns)
  • [ ] Auto-fix on save (optional)

Contributing

Found a bug? Have a feature request?

Report issues: https://github.com/josharsh/logbroom/issues

Contribute code:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see LICENSE file for details

Credits

Created by: Harsh Joshi (@josharsh)

Inspired by: Every developer who's ever shipped a debug log to production 😅


Never ship debug logs again. Install LogBroom today!

Install from Marketplace | View on GitHub | Report Issues

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft