A tool to clean logging statements from code
Project description
Log & Console Cleanup Tool
A powerful Python utility for automatically removing logging statements and console outputs from your codebase. This tool supports Python logging statements and JavaScript/TypeScript console outputs, with intelligent handling of both single-line and multi-line statements.
Features
-
Multi-Language Support
- Python (
.py) - JavaScript (
.js) - TypeScript (
.ts) - React files (
.jsx,.tsx)
- Python (
-
Smart Detection
- Identifies and removes Python logging statements (
logger.*,logging.*) - Catches all console methods in JavaScript/TypeScript
- Handles multi-line logging statements
- Preserves code formatting
- Identifies and removes Python logging statements (
-
Safety Features
- Automatic backup creation
- Detailed logging of all changes
- Preview of affected files before cleanup
- Undo capability through backups
-
User Interface
- Interactive command-line interface
- Clear progress indicators
- Colored output for better visibility
- Comprehensive summary reports
Installation
Using pip (Recommended)
You can install the package directly from GitHub:
# Install latest version
pip install git+https://github.com/cypher-o/log_cleaner.git
# Or specify a version
pip install git+https://github.com/cypher-o/log_cleaner.git@v1.0.0
From source
- Clone this repository:
git clone https://github.com/cypher-o/log_cleaner.git
cd log_cleaner
- Install in development mode:
pip install -e .
Usage
After installation, you can run the tool from anywhere using:
# Using the command-line tool
logcleaner
# Or using Python's -m flag
python -m logcleaner
Supported Patterns
Python
-
Import statements:
import logging from logging import getLogger
-
Logger initialization:
logger = logging.getLogger(__name__) _logger = logging.getLogger()
-
Logging statements (including multi-line):
logger.info("Message") logger.error(f"Error: {error}") _logger.warning( f"Warning message with " "multiple lines" )
JavaScript/TypeScript
-
Console statements:
console.log("Message"); console.error("Error"); console.warn( "Multi-line " + "warning message" );
Backup and Recovery
- Backups are stored in a
backupdirectory with timestamps - Each backup includes:
- Original files with directory structure preserved
- Detailed log file of all changes
- Timestamp-based organization for easy recovery
Examples
Basic Usage
Clean a specific directory:
python log_cleaner.py
# Select "Select a directory"
# Enter: ./my_project
Clean Specific Files
python log_cleaner.py
# Select "Select specific files"
# Enter files one by one:
# ./src/main.py
# ./src/utils.js
Best Practices
- Always run the tool on version-controlled code
- Review the summary before confirming changes
- Enable backup option for important codebases
- Test the cleaned code before committing changes
Limitations
- Does not handle extremely complex string concatenations
- Cannot detect logging statements in string literals or comments
- May require manual review for edge cases
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by the need for clean production code
- Built with best practices from Python and JavaScript communities
Support
For issues, questions, or contributions, please:
- Open an issue in the GitHub repository
- Include sample code that demonstrates the problem
- Provide the error message if applicable
- Describe the expected behavior
Changelog
v1.0.0 (2025-02-09)
- Initial release
- Multi-language support
- Backup functionality
- Interactive CLI
Made with python by Olumide Awodeji
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file log_cleaner-1.0.0.tar.gz.
File metadata
- Download URL: log_cleaner-1.0.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4855e12a54fe5da2bcdbc588b98a4835253db87c9d3325eada3ddb988ff27f9
|
|
| MD5 |
01b8f2e4712e6344eb87f3c7cb3282e8
|
|
| BLAKE2b-256 |
b93c1cb1d56ab40af7dd93227af49afb6d720d1bea2d448421cfbd4ba2fd35dc
|
File details
Details for the file log_cleaner-1.0.0-py3-none-any.whl.
File metadata
- Download URL: log_cleaner-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76a9b45bd25cac3f4c3b77ac34aca560bc4a46fef51d2f99036f26e83cd634d1
|
|
| MD5 |
d3309c5ca98eaf7e67ed4b968e0b83b4
|
|
| BLAKE2b-256 |
4f4772e946dc89259ce504b6c681580420e75a4c7e9e0a2022e98dbdf0f792c4
|