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_deletion_success_task(to: str, language: str = "en-US") -> None:
@@ -20,7 +22,7 @@ def send_deletion_success_task(to: str, language: str = "en-US") -> None:
if not mail.is_inited():
return
logging.info(click.style(f"Start send account deletion success email to {to}", fg="green"))
logger.info(click.style(f"Start send account deletion success email to {to}", fg="green"))
start_at = time.perf_counter()
try:
@@ -36,11 +38,11 @@ def send_deletion_success_task(to: str, language: str = "en-US") -> None:
)
end_at = time.perf_counter()
logging.info(
logger.info(
click.style(f"Send account deletion success email to {to}: latency: {end_at - start_at}", fg="green")
)
except Exception:
logging.exception("Send account deletion success email to %s failed", to)
logger.exception("Send account deletion success email to %s failed", to)
@shared_task(queue="mail")
@@ -56,7 +58,7 @@ def send_account_deletion_verification_code(to: str, code: str, language: str =
if not mail.is_inited():
return
logging.info(click.style(f"Start send account deletion verification code email to {to}", fg="green"))
logger.info(click.style(f"Start send account deletion verification code email to {to}", fg="green"))
start_at = time.perf_counter()
try:
@@ -72,7 +74,7 @@ def send_account_deletion_verification_code(to: str, code: str, language: str =
)
end_at = time.perf_counter()
logging.info(
logger.info(
click.style(
"Send account deletion verification code email to {} succeeded: latency: {}".format(
to, end_at - start_at
@@ -81,4 +83,4 @@ def send_account_deletion_verification_code(to: str, code: str, language: str =
)
)
except Exception:
logging.exception("Send account deletion verification code email to %s failed", to)
logger.exception("Send account deletion verification code email to %s failed", to)