Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel log stack one line
<?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
You can’t perform that action at this time.