endritvs / user-logs
Track user logs easily with this package, easy also to integrate into all Laravel projects.
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0|^10.0
This package is auto-updated.
Last update: 2024-10-31 17:39:59 UTC
README
The endritvs/user-logs
package offers a robust solution to effortlessly track and log user activities in any Laravel application. With a breezy setup, maintain logs of user interactions to gain valuable insights for debugging, monitoring, or auditing.
Features
- 🌟 Seamless Integration: Just plug, play, and track! Integrates smoothly with existing Laravel applications.
- 📂 Organized Logs: Logs neatly organized by individual user IDs, offering clear visibility into each user's actions.
- 🛠Customizable: Adjust or extend default behaviors as per your unique requirements.
- 🚀 Performance Optimized: Designed with minimal overhead to ensure smooth application performance.
Installation
-
Get the Package
Install via Composer:
composer require endritvs/user-logs:^dev-main
-
Configure Middleware
Register the middleware in your application. First, add it to the
$routeMiddleware
property of yourapp/Http/Kernel.php
file:protected $routeMiddleware = [ // ... other middleware ... 'track.user.log' => \Endritvs\UserLogs\Middleware\TrackUserLogMiddleware::class, ];
Now, you can use the
track.user.log
middleware in your routes file to apply it to individual routes or groups of routes and it will log all routes that user has accessed:Route::middleware('track.user.log')->group(function () { // ... your routes ... });
-
Configure Logging Channel
Register the custom logging channel in
config/logging.php
:'user_logs' => [ 'driver' => 'custom', 'via' => Endritvs\UserLogs\TrackUserLog::class, ]
-
More Usage if you need - Optional
You can use also Laravel's native logging system to log user activities for:
Log::channel('user_logs')->info('User performed a specific action.');
By default, logs are found in
storage/logs/user_logs
. They're sorted by user ID and the respective controller action.
Contributing
We welcome contributions! If you spot a bug, have a feature suggestion, or can enhance the current functionalities, please send a pull request.
License
This package adheres to the MIT License. Check out the LICENSE file for more details.