Another small and simple logging package. Mostly I created this for my self and wanted to simplify logging stuff for my ongoing projects.
If anyone can make use of this you're welcome to contribute or open an issue.
You can install the package via composer:
composer require devraeph/laravel-alh
You can install the package with:
php artisan alh:install
You can publish and run the migrations with:
php artisan vendor:publish --tag="laravel-alh-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="laravel-alh-config"
This is the contents of the published config file:
return [
'logging' => [
'in_productions' => env("ALH_LOG_IN_PRODUCTION",false),
"to_database" => env("ALH_TO_DB",false),
"to_file" => env("ALH_TO_FILE",true),
"file_driver" => env("ALH_FILE_DRIVER","local"),
"file_path" => env("ALH_FILE_PATH","logs_alh"),
"separate_by_type" => env("ALH_SEPARATE_BY_TYPE",false),
],
'general' => [
"clear_logs" => false,
'retention' => env("ALH_LOG_RETENTION",7), //Keep Logs for 7 days by default
],
];
Optionally, you can publish the views using
php artisan vendor:publish --tag="laravel-alh-views"
/*
* Uses default mechanism
* configured in config/alh.php
* default only toFile and not in production
*/
ALH::error("Error message",new Exception("ex"));
ALH::warning("Warning message",new Exception("ex"));
ALH::info("Info message");
ALH::success("Success message");
ALH::pending("Pending message");
/*
* Override config settings
*/
/* Log Only to DB */
ALH::toDB()->error("Error message",new Exception("ex"));
/* Log only to File */
ALH::toFile()->error("Error message",new Exception("ex"));
/* Force Log both */
ALH::toDB()->toFile()->error("Error message",new Exception("ex"));
/*
* Option to set Log issuer like User
*/
ALH::setIssuer(User::first())->error("Error message",new Exception("ex"));
protected function gate(): void
{
Gate::define('viewALH', function (User $user) {
return in_array($user->email, [
//
]);
});
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.