Comments (10)
Another case which would need to move the LoggerPass
while the compiler is optimizing the services (or after ?) rather than before. I have the following services :
<service id="service.abstract" abstract="true">
<argument type="service" id="logger" />
</service>
<service id="service.child" parent="service.abstract">
<tag name="monolog.logger" channel="test" />
</service>
As I have the same structure / constructor but for different goals (pulling different things actually), so I need a different channel for each children.
Because the pass is registered on BEFORE_OPTIMIZATION
, the service.child
's tag monolg.logger
is not used to determine which channel to use, and then fall into the app
channel.
So we basically need to currently duplicate our definitions instead of having a simple inheritance...
I guess moving this pass to AFTER_OPTIMIZATION
would be... well, optimized, but I'm not quire sure ? At least, it should be run after the ResolveDefinitionTemplatePass
. I wouldn't mind making the change, but I need to be sure that there won't be any breaks actually (or someone against it)
from monolog-bundle.
@Taluu moving it after the optimization would break thing, as the compiler pass is changing the graph of dependencies between services, and the optimizations are performed based on this dependency graph. For instance, handlers may get inlined by optimizations if the container thinks they are used by a single logger service, while they are later needed by multiple loggers and so cannot be inlined. It would also make it much harder to change the logger in private services which gets inlined and removed by optimizations, as we would have to look at any service to find inlined arguments and process them too).
from monolog-bundle.
In that case, I think the ResolveDefinitionTemplatePass
should maybe be moved into the before optimization pass, so that the dependency are kept, and passes such as the LoggerPass
could operate on the "real" and unoptimized (yet) services, but still work fine on such services, and then allowing services to be inlined etc.
But I guess this would also break things though...
So the current solution is the following :
<service id="service.child">
<1-- other services... //-->
<argument type="service" id="logger" />
<tag name="monolog.logger" channel="test" />
</service>
Which is to actually not use a service inheritance...
from monolog-bundle.
@Taluu this would be a huge BC break too, as it means that most compiler passes will become unable to use DefinitionDecorator themselves by running after the resolution.
from monolog-bundle.
Mmh so maybe the LoggerPass
should kind of copy what the ResolveDefinitionTemplatePass
does ? But that would kind of be repetitive (and how would the main one works then ?)
from monolog-bundle.
I have an idea how this could be solved
from monolog-bundle.
I don't know if it would be optimized, but maybe if, when not finding any logger
argument, it could try to lookup in a parent service if there is one (and so on, until it finds one or the service has no parent), and then change that one for the current service ?
But I think it would kind of be complicated to handle (and I'm not quite sure what it would give performance wise)
from monolog-bundle.
I just ran into this issue which is quite annoying (given I have 7 services extending an abstract one with a monolog.logger
tag as only difference). Not sure where replacing the argument in the parent service would lead, any hint about the best way to solve this?
from monolog-bundle.
I just wanted to throw the optimization AutowireRequiredMethodsPass
into the mix, as it doesn't work with tagging because the LoggerChannelPass
is executed earlier.
from monolog-bundle.
I have an idea how this could be solved
@stof What is your idea?
from monolog-bundle.
Related Issues (20)
- Monolog error after sentry added HOT 1
- fingers_crossed logs everything when a warning is logged HOT 1
- Deprecation warning on final class extension HOT 1
- Incompatibility with monolog 3.x HOT 1
- Segmentation fault on cache:clear when configuring symfony_mailer handler type HOT 4
- Bubble: false property doesn't work with doctrine channel like expected HOT 1
- Suggestion: Allow 200 status code to exclude http codes
- Allow setting exclude_fields through the bundle configuration
- Exclude unecessary files with `.gitattributes` HOT 1
- No log generated when using excluded_http_codes with some sub handlers under group (symfony/monolog-bundle 3.x). HOT 3
- Misfunction with the default prod settings and when using custom query to login HOT 1
- How to catch SlackWebhookHandler exceptions? HOT 1
- Add support for `#[Target]` attribute to autowire channels HOT 5
- WithMonologChannel on argument instead of the class HOT 1
- Handler fingers_crossed set to "error" in production prevents login in Symfony 7 without any error HOT 3
- Reset service for logs buffer HOT 3
- Add support for setting the basePath on line formatter
- Channel not used when calling function outside of class HOT 3
- Using a custom handler with a nested handler
- XSD Schema not allow %env()% syntax
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monolog-bundle.