Added JayBizzle/Laravel-Crawler-Detect to improve the error logs

This commit is contained in:
Hillel Coren 2016-08-17 12:51:26 +03:00
parent 06cce87d67
commit 60ce97fe79
4 changed files with 113 additions and 7 deletions

View File

@ -3,11 +3,13 @@
use Redirect;
use Utils;
use Exception;
use Crawler;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Validation\ValidationException;
/**
@ -39,10 +41,14 @@ class Handler extends ExceptionHandler
public function report(Exception $e)
{
// don't show these errors in the logs
if ($e instanceof HttpResponseException) {
if ($e instanceof NotFoundHttpException) {
if (Crawler::isCrawler()) {
return false;
}
} elseif ($e instanceof HttpResponseException) {
return false;
}
if (Utils::isNinja() && ! Utils::isTravis()) {
Utils::logError(Utils::getErrorString($e));
return false;
@ -83,7 +89,7 @@ class Handler extends ExceptionHandler
'error' => get_class($e),
'hideHeader' => true,
];
return response()->view('error', $data);
} else {
return parent::render($request, $e);

View File

@ -80,7 +80,8 @@
"collizo4sky/omnipay-wepay": "dev-additional-calls",
"barryvdh/laravel-ide-helper": "~2.2",
"barryvdh/laravel-debugbar": "~2.2",
"fzaninotto/faker": "^1.5"
"fzaninotto/faker": "^1.5",
"jaybizzle/laravel-crawler-detect": "1.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",

101
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "12e15e592f20359ad1085b77289bcaaa",
"content-hash": "6eafb74ed8d18816511ecbca4498304b",
"hash": "58fb4c4de809dbd2c62e2701e4c31b12",
"content-hash": "308faa59f58a34174062714c7c9c5c48",
"packages": [
{
"name": "agmscode/omnipay-agms",
@ -2727,6 +2727,103 @@
],
"time": "2015-04-20 18:58:01"
},
{
"name": "jaybizzle/crawler-detect",
"version": "v1.2.13",
"source": {
"type": "git",
"url": "https://github.com/JayBizzle/Crawler-Detect.git",
"reference": "c91439a41bda3f9eec50c13118b55ad0478fb172"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/c91439a41bda3f9eec50c13118b55ad0478fb172",
"reference": "c91439a41bda3f9eec50c13118b55ad0478fb172",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"Jaybizzle\\CrawlerDetect\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Beech",
"email": "m@rkbee.ch",
"role": "Developer"
}
],
"description": "CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent",
"homepage": "https://github.com/JayBizzle/Crawler-Detect/",
"keywords": [
"crawler",
"crawler detect",
"crawler detector",
"crawlerdetect",
"php crawler detect"
],
"time": "2016-08-09 17:10:52"
},
{
"name": "jaybizzle/laravel-crawler-detect",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/JayBizzle/Laravel-Crawler-Detect.git",
"reference": "58d1f788b68e622b860112584430dd549ad2d3d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JayBizzle/Laravel-Crawler-Detect/zipball/58d1f788b68e622b860112584430dd549ad2d3d3",
"reference": "58d1f788b68e622b860112584430dd549ad2d3d3",
"shasum": ""
},
"require": {
"jaybizzle/crawler-detect": "1.*",
"php": ">=5.4.0"
},
"require-dev": {
"orchestra/testbench": "3.0.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Jaybizzle\\LaravelCrawlerDetect\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Beech",
"email": "mbeech@mark-beech.co.uk"
}
],
"description": "A Laravel package to detect web crawlers via user agents",
"homepage": "http://github.com/JayBizzle/Laravel-Crawler-Detect",
"keywords": [
"bot",
"crawler",
"detect",
"laravel",
"spider",
"user-agent"
],
"time": "2015-08-12 20:38:34"
},
{
"name": "jeremeamia/SuperClosure",
"version": "2.2.0",

View File

@ -154,6 +154,7 @@ return [
'Jlapp\Swaggervel\SwaggervelServiceProvider',
'Maatwebsite\Excel\ExcelServiceProvider',
Websight\GcsProvider\CloudStorageServiceProvider::class,
'Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider',
/*
* Application Service Providers...
@ -255,7 +256,8 @@ return [
'Socialite' => 'Laravel\Socialite\Facades\Socialite',
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification',
'Crawler' => 'Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect',
],
];