Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] Enhance logging in compiler passes #21396

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2017
Merged

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

We should log more in compiler passes - and this should be better integrated in usual log reports.

For logging more, let's drop LoggingFormatter and add a simple "log" method on ContainerBuilder.
For better integration, let's throw silenced notices - they can be caught by our Debug handler.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jan 24, 2017

It would be great to have a profiler panel that displays the contents of the var/cache/dev/appDevDebugProjectContainerCompiler.log file btw!
Would someone like to give it a try?

@nicolas-grekas nicolas-grekas force-pushed the di-logs branch 2 times, most recently from a7f3d74 to 9f0545e Compare January 24, 2017 21:17
@@ -95,6 +102,8 @@ public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BE
*/
public function addLogMessage($string)
{
@trigger_error($string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will trigger them as E_USER_ERROR. IMO, it is too high. What about E_USER_NOTICE instead ? Lower than notice would be even better as this is a debugging info, but trigger_error does not have something lower (as it is not meant to be used as a debug logger)

btw, I'm not even convinced this is a good idea (at least not today as people will complain about silenced notices in the profiler)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the phdoc, the default is E_USER_NOTICE, so all good.
but I now made it explicit, and configurable (via a third "$level" arg)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum OK, I removed the trigger_error call for now - but kept the $level arg: even unused, it make the signature compatible with future changes requiring it.

@stof
Copy link
Member

stof commented Jan 25, 2017

The panel showing the container logs is a good idea though

@nicolas-grekas nicolas-grekas force-pushed the di-logs branch 3 times, most recently from a0623c9 to 03be6dd Compare January 25, 2017 13:46
$this->getCompiler()->log($pass, sprintf('Removed service "%s"; reason: %s.', $id, $reason));
}

public function log(CompilerPassInterface $pass, $message, $level = E_USER_NOTICE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think passing a level here makes much sense, especially not as a PHP error level. It would couple it too much to the error triggering layer, while we talk about logging here.
If you want to provide a logging level, use PSR-3 levels instead.

Btw, a way to allow flexibility about adding a level only the day we need it is to make the method final: final method can add optional args as they want (adding an optional arg only breaks BC for inheritance)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, they are final now

@nicolas-grekas nicolas-grekas force-pushed the di-logs branch 3 times, most recently from 70b9a6e to 21b8b34 Compare January 26, 2017 07:19
@nicolas-grekas
Copy link
Member Author

"logRemoveService" removed

@fabpot
Copy link
Member

fabpot commented Jan 30, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit fb200a0 into symfony:master Jan 30, 2017
fabpot added a commit that referenced this pull request Jan 30, 2017
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Enhance logging in compiler passes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

We should log more in compiler passes - and this should be better integrated in usual log reports.

For logging more, let's drop LoggingFormatter and add a simple "log" method on ContainerBuilder.
For better integration, let's throw silenced notices - they can be caught by our Debug handler.

Commits
-------

fb200a0 [DI] Enhance logging in compiler passes
@nicolas-grekas nicolas-grekas deleted the di-logs branch January 30, 2017 20:27
@fabpot fabpot mentioned this pull request May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants