StackOverflowed
StackOverflowed

Reputation: 5975

Laravel: Best way to intercept withError call

I'm currently using Laravel and I'd like to be able to extend the withError call to log it everytime it's called. I know it goes through the RedirectResponse object in this call:

public function __call($method, $parameters)
{
    if (starts_with($method, 'with'))
    {
        return $this->with(snake_case(substr($method, 4)), $parameters[0]);
    }

    throw new \BadMethodCallException("Method [$method] does not exist on Redirect.");
}

however this is part of the Illuminate (Laravel) vendor code and I Don't want to modify it in case I Want to update Laravel later. Is there a better way to do what I'm trying to do?

Upvotes: 0

Views: 217

Answers (1)

Heath N
Heath N

Reputation: 563

This should work.

App::error(function(Exception $exception)
{
    Log::error($exception);
});

References:

Upvotes: 1

Related Questions