8000 feature #26218 [MonologBridge] Allow to change level format in Consol… · symfony/symfony@dac7357 · GitHub
[go: up one dir, main page]

Skip to content

Commit dac7357

Browse files
committed
feature #26218 [MonologBridge] Allow to change level format in ConsoleFormatter (ostrolucky)
This PR was merged into the 4.1-dev branch. Discussion ---------- [MonologBridge] Allow to change level format in ConsoleFormatter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I want to use this format `%datetime% <comment>[%level_name%]</comment> %start_tag%%message%%end_tag%`, but ConsoleFormatter formats in a way message looks like this: ![screenshot from 2018-02-19 01-54-21](https://user-images.githubusercontent.com/496233/36359102-d6c20e4c-1517-11e8-9988-8a49efc4cacb.png) As you see, unnecessary padding looks like anomaly here and there is currently no way to remove it without making own formatter. This option allows me to replace default padding format with `%s`. Commits ------- fbd257c [MonologBridge] Allow to change level format
2 parents e0bdc0c + fbd257c commit dac7357

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function __construct(array $options = array())
6060
'date_format' => self::SIMPLE_DATE,
6161
'colors' => true,
6262
'multiline' => false,
63+
'level_name_format' => '%-9s',
6364
), $options);
6465

6566
if (class_exists(VarCloner::class)) {
@@ -119,7 +120,7 @@ public function format(array $record)
119120
$formatted = strtr($this->options['format'], array(
120121
'%datetime%' => $record['datetime']->format($this->options['date_format']),
121122
'%start_tag%' => sprintf('<%s>', $levelColor),
122-
'%level_name%' => sprintf('%-9s', $record['level_name']),
123+
'%level_name%' => sprintf($this->options['level_name_format'], $record['level_name']),
123124
'%end_tag%' => '</>',
124125
'%channel%' => $record['channel'],
125126
'%message%' => $this->replacePlaceHolder($record)['message'],

0 commit comments

Comments
 (0)
0