Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Log Cleaner Laravel Package

jiordiviera/laravel-log-cleaner

Laravel Log Cleaner helps you purge old Laravel log files automatically. Configure retention rules and schedule cleanup via Artisan/cron to keep storage tidy, prevent large logs, and reduce disk usage with minimal setup.

View on GitHub
Deep Wiki
Context7
v2.2.0

๐ŸŽ‰ What's New in v2.2.0

This major release introduces powerful new features for enterprise-grade log management in Laravel applications.

โœจ Major Features

๐Ÿ”ง Configuration System

  • Publishable config file - Run php artisan vendor:publish --tag="log-cleaner-config"
  • Default values for days, backup, compression, log levels
  • Memory threshold configuration for large file handling
  • Lock timeout settings for concurrent operation prevention

๐Ÿ“ก Events System

Three new Laravel events for monitoring and reacting to cleaning operations:

  • LogCleaning - Dispatched before cleaning starts
  • LogCleaned - Dispatched after cleaning completes
  • LogFileCleaned - Dispatched for each file cleaned

๐Ÿ”’ Enhanced Safety

  • File locking - Prevents concurrent cleaning operations
  • Disk space validation - Ensures sufficient space before backups
  • Backup retention - Auto-cleanup old backups (configurable max limit)

๐ŸŽจ Improved CLI

  • Beautiful table output with emoji indicators
  • Better error messages and reporting
  • New options: --no-lock, --no-events

๐Ÿงช Code Quality

  • Laravel Pint for code formatting
  • PHPStan level 4 for static analysis
  • 87.9% test coverage (62 tests, 130 assertions)
  • GitHub Actions CI with automated testing

๐Ÿ“ฆ Custom Exceptions

10 new exception classes for precise error handling:

  • InvalidDaysException
  • NoLogFilesException
  • InvalidLogLevelException
  • InvalidPatternException
  • PermissionException
  • BackupException
  • DiskSpaceException
  • FileLockException
  • ZlibException
  • LogCleanerException (base exception)

๐Ÿš€ Compatibility

PHP: 8.2+
Laravel: 10.x, 11.x, 12.x

๐Ÿ“Š Statistics

  • 62 tests passing
  • 130 assertions
  • 87.9% code coverage
  • 17 commits from this release
  • 100% backwards compatible - No breaking changes

๐Ÿ“ Documentation

  • Updated README with comprehensive examples
  • Migration guide included in CHANGELOG
  • Inline PHPDoc comments for IDE support

โฌ†๏ธ Upgrade Guide

# Update to v2.2.0
composer require jiordiviera/laravel-log-cleaner:^2.2

# (Optional) Publish the new configuration file
php artisan vendor:publish --tag="log-cleaner-config"

Breaking Changes: None - All changes are backwards compatible.

๐Ÿ™ Credits

Thanks to all contributors and users of the package!


Full Changelog: https://github.com/jiordiviera/laravel-log-cleaner/compare/v2.1.0...v2.2.0

v2.0.1

๐Ÿ”ง Enhancements & Improvements

Added

  • Disk space estimation in dry-run mode: Now shows estimated space to be freed (B/KB/MB/GB/TB)
  • Zlib extension validation: Validates zlib availability before compression operations
  • Enhanced regex pattern validation: Better error messages for invalid patterns
  • Comprehensive test suite: 26 tests with 81 assertions covering all features

Improved

  • Dry-run output now displays both line count and estimated space
  • Better error messages for invalid regex patterns with preg_last_error_msg()
  • Enhanced test coverage for compression features
  • Improved edge case handling for empty files and multiline logs

Fixed

  • Dry-run mode now properly suppresses success messages
  • Pattern validation correctly rejects invalid regex
  • Improved handling of empty log files and whitespace-only files
  • Better management of backup/compress file naming conflicts

Testing

  • โœ… 26 tests passing
  • โœ… 81 assertions
  • โœ… Full coverage: compression, combinations, edge cases
  • โœ… Performance: large file handling, memory efficiency

Example Output

$ php artisan log:clear --days=30 --dry-run
[DRY RUN] Would remove 150 lines from laravel.log
[DRY RUN] Estimated space to free: 45.2 MB

See CHANGELOG.md for full details.

v2.0.0

๐ŸŽ‰ Major Release: Performance & Memory Optimization

This release introduces significant performance improvements, memory optimization, and powerful new features for Laravel Log Cleaner.

๐Ÿš€ Key Features

Performance & Memory Optimizations

  • Memory-efficient stream processing for large files (>50MB)
  • Automatic memory threshold detection prevents out-of-memory errors
  • Stream processing handles multi-GB log files without memory issues
  • Regex pattern caching improves performance on repeated operations
  • 50%+ performance improvement on large file operations

Enhanced Safety & Robustness

  • Pre-flight permission validation prevents runtime errors
  • Backup creation with timestamp for data recovery
  • Dry-run mode for safe preview of operations
  • Enhanced error handling with detailed reporting

Advanced Filtering

  • Log level filtering (ERROR, WARNING, INFO, DEBUG, etc.)
  • Custom date patterns for non-standard log formats
  • Flexible date range selection with improved accuracy

Archive & Compression

  • Compression support for old logs instead of deletion
  • Automatic cleanup of temporary files
  • Space-efficient archiving with gzip compression

๐Ÿ“ New Command Options

Option Description
--backup Create backup before cleaning
--dry-run Preview changes without applying
--level=LEVEL Filter by log level (ERROR, WARNING, INFO, DEBUG)
--pattern=REGEX Custom date pattern matching
--compress Compress old logs instead of deleting
--memory-efficient Force memory-efficient processing

๐Ÿ’ฅ Breaking Changes

  • Minimum PHP version: 8.1+ (dropped PHP 7.x support)
  • Minimum Laravel version: 9.x+ (dropped Laravel 7.x-8.x support)

๐Ÿ”„ Migration Guide

For Users with PHP 7.x/8.0

Continue using v1.x for compatibility:

composer require jiordiviera/laravel-log-cleaner:^1.0

For Users Upgrading to v2.0

Update your PHP and Laravel versions:

composer require jiordiviera/laravel-log-cleaner:^2.0

๐Ÿ“Š Performance Benchmarks

  • Handles 1GB+ log files without memory issues
  • 50%+ performance improvement on large file operations
  • Zero memory leaks with proper resource management
  • Concurrent processing support for multiple log files

๐Ÿ› ๏ธ Usage Examples

# Preview changes (dry run)
php artisan log:clear --days=30 --dry-run

# Create backup and compress old logs
php artisan log:clear --days=30 --backup --compress

# Filter by log level
php artisan log:clear --days=0 --level=ERROR

# Custom date pattern
php artisan log:clear --days=30 --pattern="/^(\d{4}-\d{2}-\d{2})/"

# Complete workflow with all safety features
php artisan log:clear --days=30 --backup --compress --level=ERROR --dry-run

๐Ÿงช Testing

  • 11 comprehensive tests covering all new features
  • 10 GitHub Actions test matrix covering PHP 8.1-8.3 and Laravel 9-12
  • Memory efficiency testing scenarios
  • Permission validation tests

๐Ÿ™ Acknowledgments

This release addresses community feedback and provides a solid foundation for future enhancements. Thank you to all contributors and users who helped make this release possible!


Full Changelog: https://github.com/jiordiviera/laravel-log-cleaner/compare/v1.0.4...v2.0.0

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope