-
-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Description
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], ... attributes
class HomepageController extends AbstractController
{
public function __construct(
#[WithMonologChannel('homepage')]
private readonly LoggerInterface $logger,
private readonly MessageBusInterface $bus,
) {
}But, what a surprise, it didn't work.
Instead it must be set on the class
#[WithMonologChannel('homepage')]
class HomepageController extends AbstractController
{
public function __construct(
private readonly LoggerInterface $logger,
private readonly MessageBusInterface $bus,
) {
}What about allowing it on the parameter instead ? It feels more natural. And it allows having N different logger
class HomepageController extends AbstractController
{
public function __construct(
#[WithMonologChannel('homepage')]
private readonly LoggerInterface $logger,
#[WithMonologChannel('billing')]
private readonly LoggerInterface $billingLogger,
private readonly MessageBusInterface $bus,
) {
}WDYT ?
ogizanagi, Seldaek, tomme87 and lossendae
Metadata
Metadata
Assignees
Labels
No labels