Skip to content
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

[Bridge\Monolog][FrameworkBundle] Add & wire a DebugProcessor #20416

Merged
merged 1 commit into from Nov 6, 2016

Conversation

nicolas-grekas
Copy link
Member

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

As identified in #20370, collecting the log records for the profiler should happen before any processor.
The only way to do so is by registering a processor to do exactly that.
Since the last added processor is called first, this one is wired in a compiler pass that is called after other processors are registered.

The DebugHandler class being now useless, it is deprecated.
If this approach is accepted, I'll send a PR on monolog bundle & silex to leverage it.

@nicolas-grekas
Copy link
Member Author

Green on CI.
On a project that exhibited the wrong behavior, now fixed:

capture du 2016-11-04 22-47-23

'context' => $record['context'],
'channel' => isset($record['channel']) ? $record['channel'] : '',
);
switch ($record['level']) {
Copy link
Member

Choose a reason for hiding this comment

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

This switch looks unneeded. What about using a simple if?

if (in_array($record['level'], array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY))) {
    ++$this->errorCount;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Longer line, one array allocation, one function call: not my preference...

Copy link
Member

Choose a reason for hiding this comment

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

OK then ... but according to 3v4l.org, the if code generates 7 opcodes and the switch code generates 11 opcodes (although it's true that not all opcodes are equal!)

@nicolas-grekas nicolas-grekas force-pushed the debug-log-processor branch 2 times, most recently from 5271fb6 to 3f53985 Compare November 5, 2016 09:23
@fabpot
Copy link
Member

fabpot commented Nov 6, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 7572a53 into symfony:master Nov 6, 2016
fabpot added a commit that referenced this pull request Nov 6, 2016
…ocessor (nicolas-grekas)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Bridge\Monolog][FrameworkBundle] Add & wire a DebugProcessor

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

As identified in #20370, collecting the log records for the profiler should happen before any processor.
The only way to do so is by registering a processor to do exactly that.
Since the last added processor is called first, this one is wired in a compiler pass that is called after other processors are registered.

The DebugHandler class being now useless, it is deprecated.
If this approach is accepted, I'll send a PR on monolog bundle & silex to leverage it.

Commits
-------

7572a53 [Bridge\Monolog][FrameworkBundle] Add & wire a DebugProcessor
@fabpot
Copy link
Member

fabpot commented Nov 6, 2016

@nicolas-grekas Can you make the PRs on the bundle and Silex? Thanks.

@nicolas-grekas nicolas-grekas deleted the debug-log-processor branch November 6, 2016 10:27
fabpot added a commit to silexphp/Silex that referenced this pull request Nov 6, 2016
…le in MonologServiceProvider (nicolas-grekas)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

Use DebugProcessor instead of DebugHandler when available in MonologServiceProvider

Related to symfony/symfony#20416

Commits
-------

213741a Use DebugProcessor instead of DebugHandler when available in MonologServiceProvider
fabpot added a commit to symfony/monolog-bundle that referenced this pull request Nov 6, 2016
…sorPass in FrameworkBundle (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Deprecate DebugHandlerPass in favor of AddDebugLogProcessorPass in FrameworkBundle

Related to symfony/symfony#20416

Commits
-------

a55b0a0 Deprecate DebugHandlerPass in favor of AddDebugLogProcessorPass in FrameworkBundle
@fabpot fabpot mentioned this pull request Nov 17, 2016
@stof
Copy link
Member

stof commented Jan 2, 2017

@nicolas-grekas there is an issue here though: if no handler is handling the record, processors will not be called by Composer

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jan 2, 2017 via email

@sroze
Copy link
Contributor

sroze commented Sep 27, 2017

Not very useful for integration tests of processors 🤔

sroze added a commit to continuouspipe/continuouspipe that referenced this pull request Jan 7, 2018
sroze added a commit to continuouspipe/continuouspipe that referenced this pull request Feb 2, 2018
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.

None yet

6 participants