avengers-code-lovers / laravel-log-monitoring
Laravel log monitoring with log Laravel and log queue from avengers code lovers
Installs: 4 050
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 1
Forks: 4
Open Issues: 0
Requires
- php: >=7.1
- illuminate/http: ~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- illuminate/support: ~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- wataridori/chatwork-sdk: ^0.4.0
Requires (Dev)
- illuminate/contracts: ~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-11-29 06:03:46 UTC
README
To get started with Monitoring Log Laravel, use Composer to add the package to your project's dependencies:
composer require avengers-code-lovers/laravel-log-monitoring
Configuration
Laravel 5.5+
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Laravel < 5.5:
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
'providers' => [ // Other service providers... AvengersGroup\MonitoringServiceProvider::class ],
Set your session start to global middleware in app/Http/Kernel.php
protected $middleware => [ // Other global middleware... \Illuminate\Session\Middleware\StartSession::class, ]; protected $middlewareGroups => [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, //\Illuminate\Session\Middleware\StartSession::class, // Comment this // ... ], ];
You will also need to add api_key chatwork bot and room sos for services your application utilizes. These credentials should be placed in your config/services.php
configuration file, and use the key chatwork
. For example:
'chatwork' => [ 'api_key' => env('CHATWORK_API_KEY'), 'room_id_sos' => env('CHATWORK_API_ROOM_ID'), 'role' => [ 'admin' => 'admin' ] ]
Add key in .env
CHATWORK_API_KEY=xxxxx
CHATWORK_API_ROOM_ID=xxxxx
Basic Usage Monitoring Log Laravel Application Error
Add Monitoring Log Laravel reporting to App/Exceptions/Handler.php:
public function report(Exception $exception) { app('monitoring')->sendExceptionToChatWork($exception); parent::report($exception); }
Basic Usage Monitoring Log Queue Error
Follow document in https://laravel.com/docs/master/queues#cleaning-up-after-failed-jobs
/** * The job failed to process. * * @param Exception $exception * @return void */ public function failed(Exception $exception) { app('monitoring')->sendExceptionToChatWork($exception); }
Advance Usage
Monitoring Log Laravel support reporting accept $request
as param with supportable functions which come with a message with more infomation
Add Monitoring Log Laravel reporting to App/Exceptions/Handler.php:
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $exception * @return \Illuminate\Http\Response */ public function render($request, Exception $exception) { app('monitoring')->sendExceptionToChatWork($exception, $request); return parent::render($request, $exception); }