Skip to content

Commit fe1c801

Browse files
committed
Use stderr by default when a specific output is not injected
1 parent 1fdf23f commit fe1c801

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ public function close()
120120
*/
121121
public function onCommand(ConsoleCommandEvent $event)
122122
{
123-
$this->setOutput($event->getOutput());
123+
if ($event->getOutput() instanceof ConsoleOutputInterface) {
124+
$this->setOutput($event->getOutput()->getErrorOutput());
125+
} else {
126+
$this->setOutput($event->getOutput());
127+
}
124128
}
125129

126130
/**
@@ -149,11 +153,7 @@ public static function getSubscribedEvents()
149153
*/
150154
protected function write(array $record)
151155
{
152-
if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
153-
$this->output->getErrorOutput()->write((string) $record['formatted']);
154-
} else {
155-
$this->output->write((string) $record['formatted']);
156-
}
156+
$this->output->write((string) $record['formatted']);
157157
}
158158

159159
/**

0 commit comments

Comments
 (0)