Skip to content

Fix typos in code #4422

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 3 commits into from
Dec 5, 2014
Merged
Changes from 2 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
22 changes: 7 additions & 15 deletions cookbook/console/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,8 @@ First configure a listener for console terminate events in the service container
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="console_exception_listener.class">Acme\DemoBundle\EventListener\ConsoleExceptionListener</parameter>
</parameters>

<services>
<service id="kernel.listener.command_dispatch" class="%console_exception_listener.class%">
<service id="kernel.listener.command_dispatch" class="Acme\DemoBundle\EventListener\ConsoleTerminateListener">
<argument type="service" id="logger"/>
<tag name="kernel.event_listener" event="console.terminate" />
</service>
Expand All @@ -222,32 +218,28 @@ First configure a listener for console terminate events in the service container
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

$container->setParameter(
'console_exception_listener.class',
'Acme\DemoBundle\EventListener\ConsoleExceptionListener'
);
$definitionConsoleExceptionListener = new Definition(
'%console_exception_listener.class%',
$definitionConsoleTerminateListener = new Definition(
'Acme\DemoBundle\EventListener\ConsoleTerminateListener',
array(new Reference('logger'))
);
$definitionConsoleExceptionListener->addTag(
$definitionConsoleTerminateListener->addTag(
'kernel.event_listener',
array('event' => 'console.terminate')
);
$container->setDefinition(
'kernel.listener.command_dispatch',
$definitionConsoleExceptionListener
$definitionConsoleTerminateListener
);

Then implement the actual listener::

// src/Acme/DemoBundle/EventListener/ConsoleExceptionListener.php
// src/Acme/DemoBundle/EventListener/ConsoleTerminateListener.php
namespace Acme\DemoBundle\EventListener;

use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Psr\Log\LoggerInterface;

class ConsoleExceptionListener
class ConsoleTerminateListener
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This renaming is wrong IMO. ConsoleExceptionListener describes better the goal of the listener than ConsoleTerminateListener. The responsibility of the class is to log exceptions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A much better name could be ConsoleErrorLoggerListener (or ErrorLoggerListener to be shorter), given that it does not really log exceptions, but failure exit codes (logging exceptions would be on using the console.exception event)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @ifdattic It would be great if you could fix this, then we can merge these changes in!

{
private $logger;

Expand Down