Open lyrixx opened 9 months ago
Makes sense but it'll require a tweak in monolog I guess.. as that only has target_class
it also require changing entirely the way the processing is implemented. Right now, this attribute only applies the tag on the service definition, which then defines a binding.
To support separate channels in different arguments, it would require hooking directly in the autowiring logic instead.
Can you try using the Target
attribute of the DI component instead ? I think it might work already for known channels thanks to the registration done in https://github.com/symfony/monolog-bundle/blob/b2b5f9a515011b93e2bfeb814cf69613e7b7e8eb/DependencyInjection/Compiler/LoggerChannelPass.php#L151 (channels become known either because of a monolog.channel
tag asking them to be created or because of the dedicated channels
setting in the bundle configuration)
I used Target indeed 👍🏼
Hello,
I was playing with
#[WithMonologChannel]
attribute. Without reading the doc, I put it on the constructor parameter, because I thought it would work like#[Target]
,#[Autowire]
, ... attributesBut, what a surprise, it didn't work.
Instead it must be set on the class
What about allowing it on the parameter instead ? It feels more natural. And it allows having N different logger
WDYT ?