Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e494db

Browse filesBrowse files
committed
[Monolog] Added a way to configure the ConsoleFormatter from the ConsoleHandler
1 parent fec0475 commit 5e494db
Copy full SHA for 5e494db

File tree

Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
5050
OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO,
5151
OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG,
5252
];
53+
private $consoleFormaterOptions;
5354

5455
/**
5556
* @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null
@@ -58,14 +59,16 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
5859
* @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging
5960
* level (leave empty to use the default mapping)
6061
*/
61-
public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = [])
62+
public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = [], array $consoleFormaterOptions = [])
6263
{
6364
parent::__construct(Logger::DEBUG, $bubble);
6465
$this->output = $output;
6566

6667
if ($verbosityLevelMap) {
6768
$this->verbosityLevelMap = $verbosityLevelMap;
6869
}
70+
71+
$this->consoleFormaterOptions = $consoleFormaterOptions;
6972
}
7073

7174
/**
@@ -155,13 +158,13 @@ protected function getDefaultFormatter()
155158
return new LineFormatter();
156159
}
157160
if (!$this->output) {
158-
return new ConsoleFormatter();
161+
return new ConsoleFormatter($this->consoleFormaterOptions);
159162
}
160163

161-
return new ConsoleFormatter([
164+
return new ConsoleFormatter(array_replace([
162165
'colors' => $this->output->isDecorated(),
163166
'multiline' => OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity(),
164-
]);
167+
], $this->consoleFormaterOptions));
165168
}
166169

167170
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.