-
-
Notifications
You must be signed in to change notification settings - Fork 236
Add priority field to processor tags #485
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
base: master
Are you sure you want to change the base?
Conversation
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('monolog.logger')) { | ||
return; | ||
} | ||
|
||
foreach ($container->findTaggedServiceIds('monolog.processor') as $id => $tags) { | ||
foreach (array_reverse($this->findAndSortTaggedServices('monolog.processor', $container)) as $reference) { |
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.
perhaps comment why array_reverse
is used ?
otherwise its smart :)
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.
Good idea, done
So that the order in which the processors are used by monolog can be determined.
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('monolog.logger')) { | ||
return; | ||
} | ||
|
||
foreach ($container->findTaggedServiceIds('monolog.processor') as $id => $tags) { | ||
// array_reverse is used because ProcessableHandlerTrait::pushProcessor prepends processors to the beginning of the stack | ||
foreach (array_reverse($this->findAndSortTaggedServices('monolog.processor', $container)) as $reference) { |
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.
how does this behave when we have multiple tags (for instance when registering the processor in specific channels or in specific handlers ?
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.
@stof Good catch, it didn't work. I've managed to fix it. Please let me know what you think of the fix. It's probably easiest to review it with whitespace changes ignored.
@alexndlm Did you review and test the change in your projects? I agree that we should try to get it merged. |
Of course not, I have unlimited trust in Symfony 😎 But I will do this soon to double-check. |
Thank you! I personally don't need this feature at the moment. So getting feedback from someone who'd actually use it is more than valuable to us. |
Looks like PR is needed for symfony/symfony#54445? |
@nicolas-grekas no. this PR does not affect the Symfony PR (see my comment on the Symfony PR) |
@derrabus I have tested it, and it works perfectly |
@derrabus, my bad, it does not work; I have found one issue. When we add some processor only for channel And in So, when DI create The same issue should be for any channel. |
$this->assertEquals(['pushProcessor', [new Reference('test2')]], $calls[0]); | ||
$this->assertEquals(['pushProcessor', [new TypedReference('test2', 'TestClass')]], $calls[0]); | ||
|
||
$service = $container->getDefinition('monolog.handler.priority_test'); |
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.
Can we add a case when the processor has a channel?
@HypeMC, do you have time to fix this? |
Continuation of #455.