Skip to content

Commit ad071c2

Browse files
author
roissard
committed
Fix Logger::set initialization.
Using Logger::set in VoryxThruwayExtension will configure the Logger only when DI is compiling services. Use the 'enable_logging' parameter in commands.
1 parent 4259999 commit ad071c2

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/Voryx/ThruwayBundle/Command/ThruwayProcessCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ protected function configure()
8181
*/
8282
protected function execute(InputInterface $input, OutputInterface $output)
8383
{
84-
Logger::set(new NullLogger());
84+
if ($this->getContainer()->getParameter('voryx_thruway')['enable_logging'])
85+
{
86+
\Thruway\Logging\Logger::set($this->logger);
87+
}
88+
else
89+
{
90+
\Thruway\Logging\Logger::set(new \Psr\Log\NullLogger());
91+
}
8592

8693
$this->input = $input;
8794
$this->output = $output;

src/Voryx/ThruwayBundle/Command/ThruwayRouterCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ protected function configure()
3939
*/
4040
protected function execute(InputInterface $input, OutputInterface $output)
4141
{
42+
if ($this->getContainer()->getParameter('voryx_thruway')['enable_logging'])
43+
{
44+
\Thruway\Logging\Logger::set($this->logger);
45+
}
46+
else
47+
{
48+
\Thruway\Logging\Logger::set(new \Psr\Log\NullLogger());
49+
}
50+
4251
try {
4352
$output->writeln('Making a go at starting the Thruway Router');
4453

src/Voryx/ThruwayBundle/Command/ThruwayWorkerCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ protected function configure()
4343
*/
4444
protected function execute(InputInterface $input, OutputInterface $output)
4545
{
46+
if ($this->getContainer()->getParameter('voryx_thruway')['enable_logging'])
47+
{
48+
\Thruway\Logging\Logger::set($this->logger);
49+
}
50+
else
51+
{
52+
\Thruway\Logging\Logger::set(new \Psr\Log\NullLogger());
53+
}
4654

4755
try {
4856
echo "Making a go at starting a Thruway worker.\n";

0 commit comments

Comments
 (0)