pontoon icon indicating copy to clipboard operation
pontoon copied to clipboard

Update logging configuration for better debug and error tracking

Open RafaelJohn9 opened this issue 1 year ago • 3 comments

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

RafaelJohn9 avatar Jun 21 '24 07:06 RafaelJohn9

@flodolo found what the fuss was about and I have fixed it

RafaelJohn9 avatar Jun 21 '24 17:06 RafaelJohn9

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

RafaelJohn9 avatar Jun 25 '24 17:06 RafaelJohn9

hey @mathjazz , I have updated the PR, sorry for the late update.

RafaelJohn9 avatar Jul 01 '24 18:07 RafaelJohn9

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:

  1. In this patch, fix #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 motiviation for it in the issue first.

mathjazz avatar Jul 03 '24 10:07 mathjazz

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:

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

RafaelJohn9 avatar Jul 05 '24 11:07 RafaelJohn9

@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.

RafaelJohn9 avatar Jul 09 '24 02:07 RafaelJohn9

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

RafaelJohn9 avatar Jul 12 '24 05:07 RafaelJohn9

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 avatar Jul 12 '24 07:07 mathjazz

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

RafaelJohn9 avatar Jul 12 '24 16:07 RafaelJohn9

I have corrected the changes that you reviewed above.

RafaelJohn9 avatar Jul 13 '24 09:07 RafaelJohn9

Thanks for the update.

Functionality looks good, please fix the linting error and we're done!

mathjazz avatar Jul 13 '24 09:07 mathjazz

done, 👍 Learned a lot in this PR, thanks @mathjazz for your patience, 🤝 means a lot.

RafaelJohn9 avatar Jul 13 '24 10:07 RafaelJohn9

@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 avatar Jul 16 '24 11:07 mathjazz

@mathjazz done, lemme know if there is anything else required

RafaelJohn9 avatar Jul 17 '24 04:07 RafaelJohn9