devraeph / laravel-alh
Another Logging Helper for Laravel
Requires
- php: ^8.0|^8.1|^8.2
- ext-zip: *
- illuminate/contracts: ^8.0|^9.0|^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
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.
Installation
You can install the package via composer:
composer require devraeph/laravel-alh
You can install the package with:
php artisan alh:install
OR manually
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"
Usage
/* * 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"));
Access DB Logs
Dashboard at /alh-logs
The gate definition is similar to laravel/horizon
.
You can change the defaults at app/Providers/ALHMainServiceProvider.php
protected function gate(): void { Gate::define('viewALH', function (User $user) { return in_array($user->email, [ // ]); }); }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.