Skip to content

Update LoggingTranslator to log the change of a locale #31242

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

Merged
merged 1 commit into from
Apr 27, 2019

Conversation

gmponos
Copy link
Contributor

@gmponos gmponos commented Apr 25, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

I would like to see inside my logs that the translator changed the locale. I've had a case that I spent significant amount of time trying to debug it.

$this->translator->setLocale($locale);
$this->logger->debug('Translator has changed the locale.', ['previous' => $prev, 'new' => $locale]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 it can be usefull in dev

previous/next or old/new, here you use one of both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd suggest putting the locale in the message, e.g.:
The locale of the translator has changed from "%s" to "%s".

@fabpot
Copy link
Member

fabpot commented Apr 27, 2019

Thank you @gmponos.

@fabpot fabpot merged commit 20380f9 into symfony:master Apr 27, 2019
fabpot added a commit that referenced this pull request Apr 27, 2019
… (gmponos)

This PR was squashed before being merged into the 4.3-dev branch (closes #31242).

Discussion
----------

Update LoggingTranslator to log the change of a locale

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

I would like to see inside my logs that the translator changed the locale. I've had a case that I spent significant amount of time trying to debug it.

Commits
-------

20380f9 Update LoggingTranslator to log the change of a locale
@gmponos gmponos deleted the patch-3 branch April 27, 2019 19:58
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants