LogBroom - Pre-Commit Debug Log Cleaner
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 ProblemYou add The SolutionLogBroom 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
Quick Start1. Install the ExtensionSearch for "LogBroom" in VSCode Extensions marketplace, or install from CLI:
2. Stage Your Files
3. Scan for Debug LogsPress
4. Remove Debug LogsLogBroom will show you what it found. Choose:
5. Commit Clean Code
Your commit is now free of debug logs! Built-in PatternsLogBroom comes with 16 pre-configured patterns: JavaScript/TypeScript
Python
Go
Rust
Custom PatternsCreate patterns matching your debug style: Add a Pattern
Pattern Examples
Test Your Pattern
Team ConfigurationShare patterns with your team by committing a config file: Create
|
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
- Check if the file is staged:
git status
- Check if your pattern is enabled:
LogBroom: Manage Debug Patterns
- Test your pattern:
LogBroom: Test Pattern Against Current File
- 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:
- Fork the repository
- Create a feature branch
- Make your changes
- 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!