Skip to content

Commit 574f9f5

Browse files
committed
Prefer line formatter on missing cli dumper
The console formatter does a better job, unless the VarDumper component is missing, in which case you will not see the "context" or "extra" keys and the LineFormatter should be preferred.
1 parent 7ac01bc commit 574f9f5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Monolog\Handler;
1313

14+
use Monolog\Formatter\LineFormatter;
1415
use Monolog\Handler\AbstractProcessingHandler;
1516
use Monolog\Logger;
1617
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
@@ -20,6 +21,7 @@
2021
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2122
use Symfony\Component\Console\Output\OutputInterface;
2223
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
24+
use Symfony\Component\VarDumper\Dumper\CliDumper;
2325

2426
/**
2527
* Writes logs to the console output depending on its verbosity setting.
@@ -162,6 +164,9 @@ protected function write(array $record)
162164
*/
163165
protected function getDefaultFormatter()
164166
{
167+
if (!class_exists(CliDumper::class)) {
168+
return new LineFormatter();
169+
}
165170
if (!$this->output) {
166171
return new ConsoleFormatter();
167172
}

0 commit comments

Comments
 (0)