Skip to content
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

Logger proxy should be in separate repository #26

Closed
SamMousa opened this issue Mar 23, 2022 · 11 comments
Closed

Logger proxy should be in separate repository #26

SamMousa opened this issue Mar 23, 2022 · 11 comments
Labels
status:ready for adoption Feel free to implement this issue.

Comments

@SamMousa
Copy link
Contributor

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.

@samdark
Copy link
Member

samdark commented Mar 24, 2022

https://github.com/samdark/yii2-psr-log-target?

@SamMousa
Copy link
Contributor Author

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

@samdark
Copy link
Member

samdark commented Mar 30, 2022

Is it useful for more cases than the Symfony mailer?

@SamMousa
Copy link
Contributor Author

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

@samdark
Copy link
Member

samdark commented Mar 30, 2022

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

@samdark samdark added status:ready for adoption Feel free to implement this issue. and removed status:under discussion labels Mar 30, 2022
@SamMousa
Copy link
Contributor Author

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

@samdark
Copy link
Member

samdark commented Apr 15, 2022

https://github.com/yiisoft/yii2-psr-log-source

@SamMousa
Copy link
Contributor Author

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?

@samdark
Copy link
Member

samdark commented May 22, 2022

Created a file.

@samdark
Copy link
Member

samdark commented Dec 4, 2022

Is everything done here?

@SamMousa
Copy link
Contributor Author

SamMousa commented Feb 14, 2023

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());

@SamMousa SamMousa mentioned this issue Feb 14, 2023
@samdark samdark closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue.
Projects
None yet
Development

No branches or pull requests

2 participants