Created
June 1, 2019 15:10
-
-
Save neuthral/2a4b64a38b6e55f2e7393aa3f84d08be to your computer and use it in GitHub Desktop.
Laravel log stack one line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Exceptions; | |
use Log; | |
use Exception; | |
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | |
class Handler extends ExceptionHandler | |
{ | |
/** | |
* A list of the exception types that are not reported. | |
* | |
* @var array | |
*/ | |
protected $dontReport = [ | |
// | |
]; | |
/** | |
* A list of the inputs that are never flashed for validation exceptions. | |
* | |
* @var array | |
*/ | |
protected $dontFlash = [ | |
'password', | |
'password_confirmation', | |
]; | |
/** | |
* Report or log an exception. | |
* | |
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. | |
* edited to display only first line of log stack for easy reading... | |
* | |
* @param \Exception $exception | |
* @return void | |
*/ | |
public function report(Exception $e) | |
{ | |
// parent::report($e); | |
$string = ''; | |
if($e->getCode()) | |
$string .= '['.$e->getCode().'] '; | |
if($e->getMessage()) | |
$string .= $e->getMessage(); | |
if($e->getTrace()[0]['line']) | |
$string .= ' on line '.$e->getTrace()[0]['line']; | |
if($e->getTrace()[0]['file']) | |
$string .= ' of file '.$e->getTrace()[0]['file']; | |
Log::error($string); | |
} | |
/** | |
* 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) | |
{ | |
return parent::render($request, $exception); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment