salvakexx/laravel-email-logger
Composer 安装命令:
composer require salvakexx/laravel-email-logger
包简介
Simple Laravel package for logging via mail
README 文档
README
Simple Laravel package for logging via email
Installation
Add the package using composer:
composer require salvakexx/laravel-email-logger
In your config/app.php :
'providers' => [ /* * Package Service Providers... */ Salvakexx\EmailLogger\EmailLoggerServiceProvider::class, ],
'aliases' => [ /* * Class Aliases... */ 'EmailLogger' => \Salvakexx\EmailLogger\EmailLoggerFacade::class, ],
Publish the configuration file
php artisan vendor:publish --provider="Salvakexx\EmailLogger\EmailLoggerServiceProvider"
Quickstart
- Fill emails (and other parameters) in app/config/email-logger.php
'emails' => [ //fill this array with emails that will receive logs ], // 'emails' => explode(',',env('MAIL_LOGGER_EMAILS')),
- Check out your email configuration. Mail Facade must be working
Using
\EmailLogger::info(request(),'Information on action etc. '); \EmailLogger::error($exception,request(),'Error happened please check');
You can catch every exception directly, or catch all exceptions on your website. To do this override render() function in app/Exceptions/Handler.php for example :
/**
* 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)
{
//exclude the common exceptions
$exception = $this->prepareException($exception);
if(
!$exception instanceof NotFoundHttpException
&& !$exception instanceof AuthenticationException
&& !$exception instanceof ValidationException
){
\EmailLogger::error($exception,$request,'Internal Server Error happened');
}
//Track user camed to 404
if($exception instanceof NotFoundHttpException){
\EmailLogger::info($request,'User lost somehow check please');
}
return parent::render($request, $exception);
}
统计信息
- 总下载量: 267
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-23