julesgraus/actionlogs is a Laravel package for tools for logging actions.
It currently has 0 GitHub stars and 12 downloads on Packagist (latest version 1.0.0).
Install it with composer require julesgraus/actionlogs.
Discover more Laravel packages by julesgraus
or browse all Laravel packages to compare alternatives.
Last updated
Log any actions users do in your Laravel application.
You can install the package via composer:
composer require julesgraus/actionlogs
You can log actions directly like so:
JulesGraus\Actionlogs\Actionlogs::log('your action', 'a payload');
The logged action wil be linked to the authenticated user if any. The payload can be anything but a resource.
The package listens to some events in the Illuminate\Auth\Events namespace by default and automatically logs those.
This is a list of those events:
You can listen to extra events if you would like to. You could for example do that like so:
JulesGraus\Actionlogs\Actionlogs::listenToAndLog(MyCustomEvent::class, fn(MyCustomEvent::class $event) => 'Logging something for my customevent: '.$event->user->email)
Put that line of code in the register method of a service provider in your implementation.
The package is compatible with julesgraus/housekeeper. Register the JulesGraus\Actionlogs\Actionlogs class to the
housekeeper and read the published config options for more info.
publish the config files and translation file of this package by running php artisan vendor:publish --tag=actionlogs.
You can then edit the config file that will be put in the config dir.
And the translations that are put in resources/lang/vendor/actionlogs
When the default actionlog model from this package does not provide the functionality you want, you can create
a custom model yourself.
Just make sure it implements JulesGraus\Actionlogs\Contracts\Actionlog and then register it to
Laravel's container in the register method of a service provider like so:
use Illuminate\Support\ServiceProvider;
use App\Actionlogs\MyCustomActionLog;
use JulesGraus\Actionlogs\Contracts\Actionlog as ActionlogContract;
class AppServiceProvider extends ServiceProvider {
register() {
$this->app->bind(ActionlogContract::class, MyCustomActionlog::class);
}
}
Also make sure your custom implementation can accept any variable type for the payload attribute except a resource type.
Like the actionlog model you can also override other stuff by implementing
and registering these interfaces in the JulesGraus\Actionlogs\Contracts namespace:
Please bind resources and collections to a function that returns the class name of an implementation. Else Laravel will try to instantiate the classes and nag about the resource parameter that it cannot resolve.
Run tests by running this command in the root of the package.
composer test