yiisoft/yii2-symfonymailer

Logger proxy should be in separate repository

SamMousa opened this issue · 11 comments

This library contains a proxy allowing us to provide a PSR LoggerInterface and route its output to Yii's logger.
This should be in the core or a separate library, it is a useful tool with and without symfony mailer.

I'm happy to create a PR if you can create a new repo, or to create a PR for the Yii2 core, but I think that's feature frozen. Of course I could make this in my own repository as well but it would be better if it lives in yiisoft.

But this is actually the other way around right? It exposes a PSR3 Logger and sends it to Yii.

Is it useful for more cases than the Symfony mailer?

Any library that supports logging via PSR could have their logs routed to the yii log dispatcher.

OK. Do you need a repository? If so, how to name it?

Any name is fine. Maybe simliar to your yii2-psr-log-target but then yii2-psr-log-source?

I cannot fork it because it's empty. Can you give me permissions to write to the repo or create an initial commit so that I can fork and create a PR?

Created a file.

Is everything done here?

Yes, implementing it in this library is now mostly a one-liner, but I have a question.

The implementation looks like this:

$defaultFactories = Transport::getDefaultFactories(null, null, new Logger(Yii::getLogger()));

This would take a reference to the Logger, however if someone calls Yii::setLogger at any time this logger won't be updated to use the new logger. This is of course mutability issue that we have a lot in Yii2. For a library however we should probably support this mutability..

See yiisoft/yii2-psr-log-source#8 for an implementation.

If we merge that PR it would be:

$defaultFactories = Transport::getDefaultFactories(null, null, new DynamicLogger());