voryx / ThruwayBundle

Bundle for building Real-time Apps in Symfony
98 stars 47 forks source link

voryx_thruway.enable_logging doesn't act as expected #61

Open roissard opened 7 years ago

roissard commented 7 years ago

When setting voryx_thruway.enable_logging flag to false, the code in VoryxThruwayExtension.php is called only on the first run. When you relaunch the command a bit later, the log is still displayed on the console.

A suggestion would be to connect the Symfony 'logger' service to the Thruway\Logging\Logger so that the command can take benefit of -v -vv and -vvv options.

It is easy to achieve that outside of ThruwayBundle using the following code:

use Symfony\Component\Console\Event\ConsoleCommandEvent;

use Psr\Log\NullLogger;
use Thruway\Logging\Logger;

class SetVoryxLoggerListener
{

    public function onConsoleCommand(ConsoleCommandEvent $event)
    {
        Logger::set($event->getDispatcher()->getContainer()->get('logger'));
    }
}

And declare a service:

    voryx.thruway.setvorxylogger:
        class: Visioglobe\MapEditorBundle\Listener\SetVoryxLoggerListener
        tags:
            - { name: kernel.event_listener, event: console.command }