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

fix: make logger option compatible with PSR-3 Logger #12

Merged
merged 2 commits into from
Nov 30, 2022

Conversation

Schleuse
Copy link

Contrary to the documentation it's currently not possible to pass a PSR-3 logger implementation (e.g. Monolog) as the logger option, because of the types declared in the constructor of HttpClient.

According to the constructor you have to pass a DeepL\LoggerInterface. Monolog for example implements Psr\Log\LoggerInterface but of cause not DeepL\LoggerInterface.

Because of that you''ll get an Exception when you pass a Monolog logger to the logger option of the Translator:

Argument 5 passed to DeepL\HttpClient::__construct() must be an instance of DeepL\LoggerInterface or null, instance of Monolog\Logger given

This PR replaces DeepL\LoggerInterface with the Psr\Log\LoggerInterface which Monolog and other Logging Frameworks implement, making it possible to pass them as a logger to Translator.

@daniel-jones-deepl
Copy link
Member

Hi @Schleuse, thanks for the contribution, sorry that it took so long to respond. We will merge your Pull Request soon.

We were a bit unsure about adding a new dependency, but as psr/log is standardized we think it should not break backward-compatibility.

@daniel-jones-deepl daniel-jones-deepl merged commit 10ece21 into DeepLcom:main Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants