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

Improve language consistency add-on logs #12738

Open
nijel opened this issue Oct 11, 2024 · 0 comments
Open

Improve language consistency add-on logs #12738

nijel opened this issue Oct 11, 2024 · 0 comments
Assignees
Labels
enhancement Adding or requesting a new feature.

Comments

@nijel
Copy link
Member

nijel commented Oct 11, 2024

Describe the problem

Right now the add-ons log only contain information about the add-on being executed. While this is useful, it would be useful to contain more information.

Let's start with the language consistency add-on. The log should include:

  • Information on added languages
  • Information on languages which could not be added

Describe the solution you would like

The background task should extend/append the log entry.

Describe alternatives you have considered

No response

Screenshots

No response

Additional context

Probably all logging from the task should make it into add-on log:

@app.task(
trail=False,
autoretry_for=(WeblateLockTimeoutError,),
retry_backoff=600,
retry_backoff_max=3600,
)
def language_consistency(
addon_id: int, language_ids: list[int], project_id: int
) -> None:
addon = Addon.objects.get(pk=addon_id)
project = Project.objects.get(pk=project_id)
languages = Language.objects.filter(id__in=language_ids)
request = HttpRequest()
request.user = addon.addon.user
for component in project.component_set.iterator():
missing = languages.exclude(
Q(translation__component=component) | Q(component=component)
)
if not missing:
continue
component.commit_pending("language consistency", None)
for language in missing:
new_lang = component.add_new_language(
language,
request,
send_signal=False,
create_translations=False,
)
if new_lang is None:
component.log_warning(
"could not add %s language for language consistency", language
)
else:
new_lang.log_info("added for language consistency")
try:
component.create_translations_task()
except FileParseError as error:
component.log_error("could not parse translation files: %s", error)

@nijel nijel added the enhancement Adding or requesting a new feature. label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants