8000 Leverage AsMonologProcessor attribute by fancyweb · Pull Request #428 · symfony/monolog-bundle · GitHub
[go: up one dir, main page]

Skip to content

Leverage AsMonologProcessor attribute #428

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
May 10, 2022

Conversation

fancyweb
Copy link
Contributor

This feature allows configuring Monolog processors with an attribute. I basically copied AsEventListener.

@fancyweb fancyweb force-pushed the feat/as-monolog-processor branch from af9e2ed to c9fea7a Compare February 11, 2022 16:09
@derrabus
Copy link
Member

Shall we add the attribute to the Monolog Bridge instead?

@fancyweb
Copy link
Contributor Author

To use it on the Bridge's processors?

Since the tag and its attributes are only consumed by the bundle, I thought it belonged here.

@derrabus
Copy link
Member

Since the tag and its attributes are only consumed by the bundle, I thought it belonged here.

The same is true for any other As* attribute. They're all just "consumed" by FrameworkBundle, yet they reside inside the individial components. I'd place this attribute in the bridge and leave the integration logic in the bundle.

@fancyweb
Copy link
Contributor Author
fancyweb commented Feb 14, 2022

Yes but this bundle is outside symfony/symfony, doesn't it make it different?

Adding the attribute in symfony/symfony would have to be done on 6.1 as a new feature I guess. Therefore, the whole feature would only be available once 6.1 is out and only with symfony/monolog-bridge >= 6.1 😅 If everything is done here, it can be released earlier and it will be available with symfony/di >= 5.4 🤷‍♂️

@derrabus
Copy link
Member

Yes but this bundle is outside symfony/symfony, doesn't it make it different?

I don't think so. As long as we have the bridge, this is where the attribute belongs. The attribute is leveraged by your integration in this PR, but this is not the only way it could be used.

Adding the attribute in symfony/symfony would have to be done on 6.1 as a new feature I guess.

Yes.

Therefore, the whole feature would only be available once 6.1 is out and only with symfony/monolog-bridge >= 6.1

Correct. We don't deliver features for Symfony 5 anymore, so that limitation would be just fine.

@nicolas-grekas
Copy link
Member

I think we should submit the attribute to monolog!

When the attribute is set, we should also configure the binding. Here is where it's done for the corresponding marker interface.
We should preserve this behavior:

https://github.com/symfony/symfony/blob/44db49fb8f6d70c4341120a3f8f1b1a1a0dfa014/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/RegisterTokenUsageTrackingPass.php#L39-L42

@fancyweb
Copy link
Contributor Author

Thanks @derrabus and @nicolas-grekas for your explanations.

@derrabus, (and maybe @Seldaek), WDYT of adding the attribute directly in Monolog?

@derrabus
Copy link
Member

If the attribute is added to Monolog, great. If not, I'm still in favor of adding it to the bridge. 🙂

@Seldaek
Copy link
Member
Seldaek commented Feb 15, 2022

I'm not sure how much sense this makes in Monolog though as it seems really specific to the DI autowiring here, but on the other hand it's a tiny zero-maintenance piece of code so I'm also not strictly opposed to it.

The channel/handler are optional is that correct? And method is only needed if the attribute is set to a class?

@fancyweb
Copy link
Contributor Author

Everything is optional on the attribute.

If the attribute is set on a class and the method is not specified, __invoke should be used. That's what we already do here and it seems aligned with the existing ProcessorInterface in Monolog.

@Seldaek
Copy link
Member
Seldaek commented Feb 15, 2022

Oh right of course, well I guess send a PR, but please add some docs explaining the intent of each property, and a class level docblock should explain what this is meant for but that this offers no guarantee that a processor is seen as such when using Monolog alone. Or maybe we could support it too in addProcessor if the class does not implement ProcessorInterface try to read the attribute to see if a method property is defined? Anyway let's see the details on the monolog repo.

@fancyweb fancyweb force-pushed the feat/as-monolog-processor branch from c9fea7a to f1d87f0 Compare March 7, 2022 08:08
@fancyweb fancyweb changed the title Add AsMonologProcessor attribute Leverage AsMonologProcessor attribute Mar 7, 2022
@Seldaek Seldaek merged commit 598b2c5 into symfony:master May 10, 2022
@Seldaek
Copy link
Member
Seldaek commented May 10, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0