-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
How to turn off or on debug logging dynamically - ¿possible bug? #1954
Comments
You can inject your custom logger plugin: https://www.i18next.com/misc/creating-own-plugins#logger example: https://codesandbox.io/s/react-i18next-http-example-forked-kn1yuz?file=/src/i18n.js:188-363 |
@adrai thanks for the insight! It is working.... I have make a quick test...
and when var log is set to true then I see the logger log level lines in the console (and not before!) GREAT!. The motivation are to hide log lines that ng-i18next angularjs filter produces due to not having the i18next loaded yet. If you can provime me context about what I was doing with I will appreciate it very much as well!. TD;DR; The problem with ng-i18next, the commented lines were a proposal to fix them... |
There's just 1 instance of the logger so I would use |
I'm afraid i18next.logger.setDebug(false or true) doesn't makes any visible effect on the log IF the log starts with debug false then in keep "muted" besides doing My version of i18next.js is 21.6.16 |
currently afk, will check later |
Sorry, I was wrong... there is not a single instance of the logger... each sub-module creates its own logger instance... |
yes there are "sub-loggers" but as far as I know only for the translator module... I never saw a use case beside having the logger turned on/off once using options on init -> debug is only set to true in development env anyway....so who cares about getting those warnings as they are not logged during production enabling both loggers (main instance and the one on translator should be sufficient). I still wouldn't change the setDebug on an instance to toggle behaviour on all. If that's needed a copy of the base logger should do. |
beside that - what comes next. Turn off warnings if a namespace was not loaded as the implementation for the UI framework has no |
since the setDebug function is not used at all we maybe should remove it completely |
would be breaking change...as it could be used in userland (just not used internal)...in the end...all can be done...it's just not one global toggle... // turn all on
i18next.logger.setDebug(true);
i18next.translator.logger.setDebug(true);
Object.values(i18next.services).forEach(s => s.logger && s.logger.setDebug(true)); |
@adrai @jamuhl thanks for adressing this issue. It is not something crucial, but desirable to have it working. It happens on specific scenario due to some code of ng-i18next that try to translate prior of having i18next initialized. And I agree that the problem shall be fixed at ng-i18next level, and not here. But the ng-i18next project looks quite abandoned.... I mean, I have filled a bug some months ago and there was no reply. Leaving that aside and if you may allow a personal opinion => I think that the setDebug(true or false) shall be working as expected. Right now is a no op, so, you may document it well or you may fix it. There can be other cases in the future where devs would like to turn on or off this feature. Using a custom logger works like a charm, so that was a good workaround for this. Thanks for taking into consideration this affair, and keep up the good work!. |
Hi Folks! Hope you are doing fine.
Sorry to bother....
I'm having this situation. I don't know what door to knock, so I posted in stackoverflow and here.
Thanks in advance!
The text was updated successfully, but these errors were encountered: