Update logging configuration for better debug and error tracking
Fix #3192
-
Added rotating file handlers for Django and Pontoon loggers
-
Console logging now uses verbose format in DEBUG mode
-
Improved log formatting for clarity and consistency
-
added *.log in .gitignore to prevent log files from being pushed
@flodolo found what the fuss was about and I have fixed it
Thanks for the patch! Nice work!
I'd like the logging settings to remain exactly the same as they are ATM.
All the changes (logging to a file, logging format) should be optional and controlled via environment variables.
sure thing I'll update that
hey @mathjazz , I have updated the PR, sorry for the late update.
Thanks for the update!
Logging is apparently still more verbose than on main, e.g. I see the following message in the logs:
[server] [DEBUG:django.db.backends] 2024-07-03 10:24:58,130 (0.000) SELECT "base_project"."id", "base_project"."total_strings", "base_project"."approved_strings", "base_project"."pretranslated_strings", "base_project"."strings_with_errors", "base_project"."strings_with_warnings", "base_project"."unreviewed_strings", "base_project"."name", "base_project"."slug", "base_project"."data_source", "base_project"."can_be_requested", "base_project"."configuration_file", "base_project"."disabled", "base_project"."date_created", "base_project"."date_disabled", "base_project"."sync_disabled", "base_project"."system_project", "base_project"."visibility", "base_project"."langpack_url", "base_project"."info", "base_project"."deadline", "base_project"."priority", "base_project"."contact_id", "base_project"."admin_notes", "base_project"."latest_translation_id", "base_project"."tags_enabled", "base_project"."pretranslation_enabled" FROM "base_project" WHERE "base_project"."id" IN (1) ORDER BY "base_project"."id" ASC; args=(1,); alias=default
Could we split this patch into two pieces? Namely:
- In this patch, fix #3192, i.e. only add ability to optionally log to a file.
- File a separate bug to enable more verbose logging, and hash out the motiviation for it in the issue first.
Thanks for the update!
Logging is apparently still more verbose than on
main, e.g. I see the following message in the logs:[server] [DEBUG:django.db.backends] 2024-07-03 10:24:58,130 (0.000) SELECT "base_project"."id", "base_project"."total_strings", "base_project"."approved_strings", "base_project"."pretranslated_strings", "base_project"."strings_with_errors", "base_project"."strings_with_warnings", "base_project"."unreviewed_strings", "base_project"."name", "base_project"."slug", "base_project"."data_source", "base_project"."can_be_requested", "base_project"."configuration_file", "base_project"."disabled", "base_project"."date_created", "base_project"."date_disabled", "base_project"."sync_disabled", "base_project"."system_project", "base_project"."visibility", "base_project"."langpack_url", "base_project"."info", "base_project"."deadline", "base_project"."priority", "base_project"."contact_id", "base_project"."admin_notes", "base_project"."latest_translation_id", "base_project"."tags_enabled", "base_project"."pretranslation_enabled" FROM "base_project" WHERE "base_project"."id" IN (1) ORDER BY "base_project"."id" ASC; args=(1,); alias=defaultCould we split this patch into two pieces? Namely:
1. In this patch, fix [Ability to log in a file #3192](https://github.com/mozilla/pontoon/issues/3192), i.e. only add ability to optionally log to a file. 2. File a separate bug to enable more verbose logging, and hash out the motivation for it in the issue first.
Sure thing. Sorry about the more verbose logging, I'll remove the more verbose logging and focus on the task at hand
@mathjazz I have removed the simple, logging option, I have looked at the verbose logging options and I noticed it's currently the same as yours.
hello @mathjazz am really interested in this project, this PR is taking almost a month now 😅, if you don't mind could you give one of your social platforms you are active in so that we could talk more about how you want me to approach this issue, and hence a smooth workflow for future issues and PRs
Hey @RafaelJohn9, thanks for your contribution and patience!
See the README for contact information (I'm mathjazz on chat.mozilla.org and other channels): https://github.com/mozilla/pontoon?tab=readme-ov-file#contributing-to-pontoon
As mentioned earlier, #3192 is only about adding the ability to log to a file. There's still a few changes in this PR that are not needed for that.
As soon as this is addressed, we can ship this.
Hey @RafaelJohn9, thanks for your contribution and patience!
See the README for contact information (I'm mathjazz on chat.mozilla.org and other channels): https://github.com/mozilla/pontoon?tab=readme-ov-file#contributing-to-pontoon
As mentioned earlier, #3192 is only about adding the ability to log to a file. There's still a few changes in this PR that are not needed for that.
As soon as this is addressed, we can ship this.
@mathjazz I'll contact you tomorrow if you are okay with it, to talk more about this
I have corrected the changes that you reviewed above.
Thanks for the update.
Functionality looks good, please fix the linting error and we're done!
done, 👍 Learned a lot in this PR, thanks @mathjazz for your patience, 🤝 means a lot.
@RafaelJohn9 Could you please document the newly added environment variable: https://github.com/mozilla/pontoon/blob/main/docs/admin/deployment.rst#environment-variables
Sorry I missed that earlier!
@mathjazz done, lemme know if there is anything else required