Skip to content

Listens on console.command to trigger client load #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Sentry/SentryBundle/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Sentry\SentryBundle\Event\SentryUserContextEvent;
use Sentry\SentryBundle\SentrySymfonyClient;
use Sentry\SentryBundle\SentrySymfonyEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand Down Expand Up @@ -111,6 +112,19 @@ public function onKernelException(GetResponseForExceptionEvent $event)
$this->client->captureException($exception);
}

/**
* This method only ensures that the client and error handlers are registered at the start of the command
* execution cycle, and not only on exceptions
*
* @param ConsoleCommandEvent $event
*
* @return void
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
// only triggers loading of client, does not need to do anything.
}

/**
* @param ConsoleExceptionEvent $event
*/
Expand Down
1 change: 1 addition & 0 deletions src/Sentry/SentryBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ services:
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: '%sentry.listener_priorities.request%'}
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: '%sentry.listener_priorities.kernel_exception%' }
- { name: kernel.event_listener, event: console.command, method: onConsoleCommand }
- { name: kernel.event_listener, event: console.exception, method: onConsoleException, priority: '%sentry.listener_priorities.console_exception%' }
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public function test_that_it_has_proper_event_listener_tags_for_exception_listen
array(
array('event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => '%sentry.listener_priorities.request%' ),
array('event' => 'kernel.exception', 'method' => 'onKernelException', 'priority' => '%sentry.listener_priorities.kernel_exception%'),
array('event' => 'console.command', 'method' => 'onConsoleCommand'),
array('event' => 'console.exception', 'method' => 'onConsoleException', 'priority' => '%sentry.listener_priorities.console_exception%'),
),
$tags
Expand Down