Download the PHP package motakabbir/activity-logger without Composer
On this page you can find all versions of the php package motakabbir/activity-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download motakabbir/activity-logger
More information about motakabbir/activity-logger
Files in motakabbir/activity-logger
Package activity-logger
Short Description A powerful Laravel package for automatically tracking model changes and user activities with IP tracking
License MIT
Homepage https://github.com/Motakabbir/activity-logger
Informations about the package activity-logger
Activity Logger Package
A powerful and easy-to-use Laravel package for automatically tracking model changes and user activities within your application. This package provides automatic model tracking and manual activity logging capabilities.
Requirements
- PHP 7.4 or higher
- Laravel 8.0 or higher
- MySQL 5.7+ or PostgreSQL 9.6+
Installation
To install the Activity Logger Package, you can use Composer:
Configuration
After installation, publish the configuration and migrations:
Then run the migrations:
Configuration Options
The package can be configured through the config/activity-logger.php
file. Here are all available options:
Usage
Automatic Model Activity Logging
Simply add the LogsActivity
trait to any model you want to track:
Now all create/update/delete operations on this model will be automatically logged!
Configuring Attribute Logging
You can configure which attributes to log in three ways:
-
In your model using properties:
-
In the configuration file for all models:
- Let the package log all attributes (default behavior if no configuration is provided)
The priority order is:
- Model-specific configuration (
$logAttributes
or$logExcept
in the model) - Global configuration in
config/activity-logger.php
- Log all attributes if no configuration is found
Sensitive fields defined in sensitive_fields
will always be masked with '**' in the logs, regardless of how attributes are configured.
Retrieving Logs for a Model
Manual Logging
You can also log activities manually using the facade:
Cleanup Old Records
To clean up old activity logs, you can use the provided artisan command:
This command will delete records older than the configured retention period (keep_logs_for_days
).
Customization
Custom Activity Model
You can use your own activity model by specifying it in the configuration:
Your custom model should extend the base ActivityLog
model or implement the same interface.
Queue Configuration
To improve performance, you can enable queued logging:
This will process the activity logging in the background.
Testing
To run the tests for the Activity Logger Package, use PHPUnit:
License
This package is open-source and available under the MIT License. See the LICENSE file for more information.
Contributing
Contributions are welcome! If you would like to contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please make sure to update tests as appropriate and follow the existing coding style.