Refactor: use logger = logging.getLogger(__name__) in logging (#24515)

Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
Yongtao Huang
2025-08-26 18:10:31 +08:00
committed by GitHub
parent 8af2ae973f
commit fa753239ad
102 changed files with 565 additions and 401 deletions

View File

@@ -7,6 +7,8 @@ from celery import shared_task
from extensions.ext_mail import mail
from libs.email_i18n import EmailType, get_email_i18n_service
logger = logging.getLogger(__name__)
@shared_task(queue="mail")
def send_change_mail_task(language: str, to: str, code: str, phase: str) -> None:
@@ -22,7 +24,7 @@ def send_change_mail_task(language: str, to: str, code: str, phase: str) -> None
if not mail.is_inited():
return
logging.info(click.style(f"Start change email mail to {to}", fg="green"))
logger.info(click.style(f"Start change email mail to {to}", fg="green"))
start_at = time.perf_counter()
try:
@@ -35,9 +37,9 @@ def send_change_mail_task(language: str, to: str, code: str, phase: str) -> None
)
end_at = time.perf_counter()
logging.info(click.style(f"Send change email mail to {to} succeeded: latency: {end_at - start_at}", fg="green"))
logger.info(click.style(f"Send change email mail to {to} succeeded: latency: {end_at - start_at}", fg="green"))
except Exception:
logging.exception("Send change email mail to %s failed", to)
logger.exception("Send change email mail to %s failed", to)
@shared_task(queue="mail")
@@ -52,7 +54,7 @@ def send_change_mail_completed_notification_task(language: str, to: str) -> None
if not mail.is_inited():
return
logging.info(click.style(f"Start change email completed notify mail to {to}", fg="green"))
logger.info(click.style(f"Start change email completed notify mail to {to}", fg="green"))
start_at = time.perf_counter()
try:
@@ -68,11 +70,11 @@ def send_change_mail_completed_notification_task(language: str, to: str) -> None
)
end_at = time.perf_counter()
logging.info(
logger.info(
click.style(
f"Send change email completed mail to {to} succeeded: latency: {end_at - start_at}",
fg="green",
)
)
except Exception:
logging.exception("Send change email completed mail to %s failed", to)
logger.exception("Send change email completed mail to %s failed", to)