Symfony2 ConsoleExceptionListener ConsoleExceptionEvent get Arguments and Options

82 Views Asked by At

I have implemented a console exception listener exactly as explained in http://symfony.com/doc/current/cookbook/console/logging.html#enabling-automatic-exceptions-logging it works as expected.

But I have some cronjobs that execute some commands that require arguments and options and I would like to add this arguments and options to my log, to have a more specific detail of what caused an error.

How can I do that? Inside the command class I haven't see a public function to get the arguments or options

1

There are 1 best solutions below

0
On

I found the answer I was looking in the wrong place

$command = $event->getCommand();

As described in the question Command has no methods to get it

but

ConsoleExceptionEvent $event

has a method to get the input (Arguments and Options)

$event->getInput();