Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Bridge/Monolog] Enhance the Console Handler#21705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
3ae3f06 to4103b61Compare| } | ||
| if (isset($args[1])) { | ||
| $options['date_format'] =$args[1]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about the two last arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
They are not relevant anymore. So I don't need to "map" them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
shouldn't$allowInlineLineBreaks map tomultiline ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeed. I will fix it in the next pr. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
So you intentionally removed the option to suppress emtpy context and extra data?
Update: Just saw that this was mentioned in#21705 (comment) as well.
| publicfunction__construct($options =array()) | ||
| { | ||
| parent::__construct($format,$dateFormat,$allowInlineLineBreaks,$ignoreEmptyContextAndExtra); | ||
| // BC Layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You might want to document what the signature you're emulating here looks like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sure ;) And I have to add a trigger_error too. I just wait some feedback before.
| 'multiline' =>false, | ||
| ),$options); | ||
| $this->cloner =newVarCloner(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No DI here or line 83?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No indeed. IMHO it's useless and there are other part of the framework where the dumper / cloner is hard-coded like that.
About the line 83, I cannot anyway as I do need a CLIDumper and well configured.
4103b61 to5fe4af5Comparelyrixx commentedFeb 21, 2017
5fe4af5 to6823479Compare| */ | ||
| publicfunction__construct($options =array()) | ||
| { | ||
| // BC Layer, old constructor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What I meant by "documenting what it looks like" was more sth like :
// BC layer for this signature : __construct($format = null, $dateFormat = null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actually, it's "documented" just bellow in the trigger error message.
For the record, I added what you asked for, then I added the deprecation, then I removed because it was a kind of duplicate. and now I notice I forgot to remove, old constructor:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Alright!
| { | ||
| // BC Layer, old constructor: | ||
| if (!is_array($options)) { | ||
| @trigger_error(sprintf('The constructor arguments $format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra of %s are deprecated and will be removed in 4.0. Use $options insteand.',self::class),E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
insteand => instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks. Fixed.
6823479 to2f01f9fComparegreg0ire commentedFeb 22, 2017
In your commit message : - Basically, The formatter now use the VarDumper & use more significant…+ Basically, the formatter now uses the VarDumper & uses more significant… |
b516ef7 to1ba3fcdCompare1ba3fcd to7a2de64Comparelyrixx commentedFeb 22, 2017
Looks like the This PR is now ready for the review ;) |
romainneutron left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
| { | ||
| // BC Layer | ||
| if (!is_array($options)) { | ||
| @trigger_error(sprintf('The constructor arguments $format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra of %s are deprecated and will be removed in 4.0. Use $options instead.',self::class),E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Missing quotes around%s (should be"%s")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
are deprecated since 3.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks; fixed.
| ),$options); | ||
| if (!class_exists(VarCloner::class)) { | ||
| thrownew \RuntimeException('To use the ConsoleFormatter you must install the symfony/var-dumper component.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This could be moved to the top, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks. Fixed.
7a2de64 todf24afcComparefabpot commentedFeb 22, 2017
Quick question: would it be possible to fallback to the old way when vardumper is not installed? |
lyrixx commentedFeb 22, 2017
It's not really easy (but not impossible) since the We can create two Another solution is to extends again the LineFormatter. What is the best option to you? |
| constSIMPLE_DATE ='H:i:s'; | ||
| privatestatic$levelColorMap =array( | ||
| 100 =>'fg=white', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
what's about using monolog's (or PSR) constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
- because the map will not be aligned ;) just kidding !
- PSR contant with int level does not exist
I updated the PR to use Monolog\Logger::CONSTANT
df24afc to5fa5041Comparefabpot commentedMar 1, 2017
@lyrixx, I think we still need to support the case where |
lyrixx commentedMar 6, 2017
I pushed a new version: Now if the var-dumper component is not installed, the context and the extra are not dumped at all. I chose to do that in order tokeep the code as simple as possible. I could also extends the NormalizeFormatter, but there is lot of code in the LineFormatter. So I don't think it worth it. |
| private$dumper; | ||
| /** | ||
| * {@inheritdoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This should be removed as you don't extend anything anymore. Also, the phpdoc should document the available option keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks. I updated the PHP Doc.
a11d586 to69ec738Comparefabpot commentedMar 6, 2017
Last thing, can you add a note in the CHANGELOG? |
Basically, the formatter now uses the VarDumper & uses more significantcolors and has a more compact / readable format (IMHO).
lyrixx commentedMar 6, 2017
Done ;) |
fabpot commentedMar 6, 2017
Thank you@lyrixx. |
This PR was merged into the 3.3-dev branch.Discussion----------[Bridge/Monolog] Enhance the Console Handler| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | -| Fixed tickets | -| License | MIT| Doc PR | ----I extracted and enhanced the formatting logic from#21080.Basically, The formatter now use the VarDumper & use more significant colors and has a more compact / readable format (IMHO).---I used the following code to generate before/after screenshots.```php protected function execute(InputInterface $input, OutputInterface $output) { $logger = $this->getContainer()->get('logger'); $filesystem = $this->getContainer()->get('filesystem'); $anObject = new \stdClass; $anObject->firstPpt = 'foo'; $anObject->secondePpt = 'bar'; $logger->log('notice', 'Hello {who}', [ 'who' => 'Wold', 'an_object' => $anObject, 'file_system' => $filesystem, ]); $r = new \ReflectionClass(LogLevel::class); foreach ($r->getConstants() as $level) { $logger = $logger->withName($level); $logger->log($level, 'log at level {level}', [ 'level' => $level, ]); } }```before:After:Commits-------b663ab5 [Bridge/Monolog] Enhanced the Console Handler
Related tosymfony/symfony#21705Note: It's not an issue to let monolog doing it, but if monolog do itsymfony can not do it. The best experience is when symfony do it.So let's disable it.
…symfony. (lyrixx)This PR was merged into the 3.3-dev branch.Discussion----------Do not process psr_3 log messages, as it's now done by symfony.Related tosymfony/symfony#21705Note: It's not an issue to let monolog doing it, but if monolog do itsymfony can not do it. The best experience is when symfony do it.So let's disable it.Commits-------ebe2bad Do not process psr_3 log messages, as it's now done by symfony.
mvrhov commentedMar 9, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This seems to be a memory hog. At least I was greeted with the php terminating script due to memory exhaustion (128M) instead of getting the stack dump. I have run the command with time to see the top memory consumption and it was around 150M-160M. Running same command with 3.2, the memory used is around 50M |
lyrixx commentedMar 9, 2017
@mvrhov Thanks for reporting this, but could you open a new issue and ping me to keep a trace of this issue? |
Tobion commentedMay 20, 2017
Does this PR basically revert#11496? I don't see why. |
…xt and extra data (mpdude)This PR was squashed before being merged into the 3.4 branch (closes#28471).Discussion----------[MonologBridge] Re-add option option to ignore empty context and extra data| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets || License | MIT| Doc PR |In#11496, an option was added to `ConsoleFormatter` to ignore empty context and extra data. This setting was even turned on by default.The `ConsoleHandler` was then overhauled in#21705. During this change, the option got lost.Commits-------d1e7438 [MonologBridge] Re-add option option to ignore empty context and extra data

Uh oh!
There was an error while loading.Please reload this page.
I extracted and enhanced the formatting logic from#21080.
Basically, The formatter now use the VarDumper & use more significant colors and has a more compact / readable format (IMHO).
I used the following code to generate before/after screenshots.
before:
After: