sinarajabpour1998 / log-manager
This package provides log manager in laravel apps.
Installs: 53
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Type:laravel-package
Requires
- php: 7.1.*|7.2.*|7.3.*|7.4.*|8.*
- laravel/framework: 7.*|8.*
- sinarajabpour1998/alpha-helper: 1.*
README
This package provides log manager for laravel apps.
Installation
Using Composer :
composer require sinarajabpour1998/log-manager
packagist : log-manager
Usage
- Publish blade files
php artisan vendor:publish --tag=log-manager
** Please note if you already published the vendor, for updates you can run the following command :
php artisan vendor:publish --tag=log-manager --force
- Run migration command :
php artisan migrate
- Add the following tag in your sidebar layout :
<x-log-menu></x-log-menu>
or shorten tag :
<x-log-menu />
Save custom logs
- First define some log types in log-manager config :
Types structure: "type" => "type_name"
[ "log_types" => [ "login" => "ورود به سایت", "registration" => "ثبت نام در سایت" ] ];
- Add the following code anywhere you want (be careful about namespace)
use Sinarajabpour1998\LogManager\Facades\LogFacade; LogFacade::generateLog("login");
Done ! now all the logs will be saved in the logs table
Save system error logs
Edit the following file :
app\Exceptions\Handler.php
Your register method in Exception handler must be like this :
use Sinarajabpour1998\LogManager\Facades\LogFacade; /** * Register the exception handling callbacks for the application. * * @return void */ public function register() { $this->reportable(function (Throwable $e) { // Added for log-manager if ($this->shouldReport($e)){ LogFacade::generateErrorLog($e); } }); }
Done ! now all the system error logs will be saved in the error_logs table
Config options
You can set custom permissions for each section of this package. make sure that you already specified permissions in a seeder.
Also you need log_types before get started with custom logs.