Log Removal is a command-line tool designed to clean up Dart/Flutter projects by removing unwanted log statements, such as print
, debugPrint
, logger
, and other custom log patterns.
This tool allows users to select predefined log patterns or add their custom patterns using regular expressions (regex). It can be installed globally for seamless usage across multiple projects.
- Global Usage: Install once and use it in all your Dart/Flutter projects.
- Multi-select: Remove multiple log patterns in one go.
- Custom Patterns: Add custom log patterns with regex.
- High Compatibility: Specifically built for Dart and Flutter projects.
- User-Friendly: A simple text-based interface to select files or folders for processing.
Install Log Removal globally to use it across all your projects with the following command:
dart pub global activate log_removal
After installation, the log_removal
command will be available globally in your terminal, ready to use in any project directory.
If you want to use Log Removal in a specific project, add it as a dependency:
dependencies:
log_removal: <latest_version>
Then, run it using the following command within the project:
dart run log_removal
Once installed, run the program with:
log_removal
Choose one of the following options:
- Specific File: Clean logs from a specific file.
- Specific Folder: Clean logs from a specific folder.
- Entire Project: Clean logs from the entire project.
The program will display a list of log patterns to remove, such as:
print(...)
debugPrint(...)
logger.*(...)
logMessage(...)
You can select multiple patterns or add a custom pattern using regex.
After processing, the program will display:
- The number of files processed.
- The number of logs removed.
$ log_removal
🔧 Welcome to Log Removal!
Let's clean up your project from unwanted logs. 🚀
📂 Select a folder from the current directory:
✅ Folder selected: /path/to/project
Choose log patterns to remove:
[0] print(...)
[1] debugPrint(...)
[2] logger.*(...)
[3] logMessage(...)
[4] Custom pattern
Select options (e.g., 0,1,3): 0,1,4
🔧 Enter your custom regex pattern:
^\s*customLog\(.*\);\s*$
✅ Custom pattern added.
✅ Log removal completed.
📁 Files Processed: 5
The predefined log patterns include:
print(...)
: Matchesprint()
statements.debugPrint(...)
: MatchesdebugPrint()
statements.logger.*(...)
: Matches logging functions likelogger.d()
orlogger.e()
.logMessage(...)
: Matches custom log functions likelogMessage()
.
In addition to these, you can add custom log patterns using name of log to handle unique logging formats in your projects.
Contributions are welcome!
To contribute:
- Fork this repository.
- Create a new branch for your feature or fix.
- Submit a pull request with a clear description of your changes.
This project is licensed under the MIT License.
This version is cleaner, more concise, and user-friendly. 🎉