From 1e5064007b1c54f4e2e8ad3d90b51080cd221b72 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 14 Oct 2020 02:11:14 +0200 Subject: [PATCH] TT#96400 improve celery logging for worker Change-Id: I47c64372d341042746b3f4a37d1ce4bf5f72d00e --- build/tasks.py | 11 ++++++----- hotfix/tasks.py | 7 +++---- release_changed/tasks.py | 7 ++++--- release_dashboard/tasks.py | 7 +++---- repoapi/tasks.py | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/tasks.py b/build/tasks.py index ee0d226..39074ef 100644 --- a/build/tasks.py +++ b/build/tasks.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 The Sipwise Team - http://sipwise.com +# Copyright (C) 2017-2020 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,9 +12,8 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -import logging - from celery import shared_task +from celery.utils.log import get_task_logger from .conf import settings from build.models.br import BuildRelease @@ -22,7 +21,7 @@ from build.utils import trigger_build from build.utils import trigger_copy_deps from repoapi.celery import app -logger = logging.getLogger(__name__) +logger = get_task_logger(__name__) @app.task(bind=True) @@ -37,7 +36,9 @@ def build_release(self, pk): else: release = instance.release url = trigger_copy_deps( - release=release, internal=True, release_uuid=instance.uuid, + release=release, + internal=True, + release_uuid=instance.uuid, ) logger.info("%s triggered" % url) diff --git a/hotfix/tasks.py b/hotfix/tasks.py index 8e705c5..4536a49 100644 --- a/hotfix/tasks.py +++ b/hotfix/tasks.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 The Sipwise Team - http://sipwise.com +# Copyright (C) 2016-2020 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,14 +12,13 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -import logging - from celery import shared_task +from celery.utils.log import get_task_logger from .utils import process_hotfix from repoapi.models import JenkinsBuildInfo -logger = logging.getLogger(__name__) +logger = get_task_logger(__name__) @shared_task(ignore_result=True) diff --git a/release_changed/tasks.py b/release_changed/tasks.py index 8786e00..021f9ff 100644 --- a/release_changed/tasks.py +++ b/release_changed/tasks.py @@ -13,14 +13,14 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . import json -import logging from celery import shared_task +from celery.utils.log import get_task_logger from django.apps import apps from .models import ReleaseChanged -logger = logging.getLogger(__name__) +logger = get_task_logger(__name__) @shared_task(ignore_result=True) @@ -32,7 +32,8 @@ def process_result(jbi_id, path_envVars): info = data["envMap"] if info["vmdone"] == "yes": ReleaseChanged.objects.filter( - version=info["vmversion"], vmtype=info["vmtype"], + version=info["vmversion"], + vmtype=info["vmtype"], ).delete() logger.info("{}_{} deleted".format(info["vmtype"], info["vmversion"])) return diff --git a/release_dashboard/tasks.py b/release_dashboard/tasks.py index ff073e1..158b7fb 100644 --- a/release_dashboard/tasks.py +++ b/release_dashboard/tasks.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 The Sipwise Team - http://sipwise.com +# Copyright (C) 2016-2020 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,9 +12,8 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -import logging - from celery import shared_task +from celery.utils.log import get_task_logger from .conf import settings from .models import DockerImage @@ -23,7 +22,7 @@ from .models import Project from .utils import build from .utils import docker -logger = logging.getLogger(__name__) +logger = get_task_logger(__name__) @shared_task(ignore_result=True) diff --git a/repoapi/tasks.py b/repoapi/tasks.py index bec68d8..9b981f0 100644 --- a/repoapi/tasks.py +++ b/repoapi/tasks.py @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . import json -import logging from datetime import timedelta from os.path import basename from celery import shared_task +from celery.utils.log import get_task_logger from django.apps import apps from .celery import app @@ -29,7 +29,7 @@ from .utils import jenkins_get_build from .utils import jenkins_get_console from .utils import jenkins_get_env -logger = logging.getLogger(__name__) +logger = get_task_logger(__name__) @shared_task(ignore_result=True)