From df6ee1ba6dfbd7ccc68ff4f12eecf33cc8328959 Mon Sep 17 00:00:00 2001 From: H Vs Date: Tue, 1 Apr 2025 10:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/log.py | 22 ++++++++++++++++++++++ tasks.py | 7 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/common/log.py b/common/log.py index 583d1b8..ef5d4fd 100644 --- a/common/log.py +++ b/common/log.py @@ -172,5 +172,27 @@ def configure_fastapi_logging(): _reset_logger(fastapi_logger) fastapi_logger.setLevel(logging.INFO) +# Celery 日志配置 +def configure_celery_logging(): + """配置 Celery 的日志记录""" + celery_logger = logging.getLogger("celery") + _reset_logger(celery_logger) + celery_logger.setLevel(logging.INFO) + +# Celery RedBeat 日志配置 +def configure_redbeat_logging(): + """配置 Celery RedBeat 的日志记录""" + redbeat_logger = logging.getLogger("redbeat") + _reset_logger(redbeat_logger) + redbeat_logger.setLevel(logging.INFO) + + # 配置 FastAPI 日志 configure_fastapi_logging() + +# 配置 Celery 日志 +configure_celery_logging() + + +# 配置 Redbeat 日志 +configure_redbeat_logging() diff --git a/tasks.py b/tasks.py index 4d8e6ef..13e2790 100644 --- a/tasks.py +++ b/tasks.py @@ -230,7 +230,12 @@ def scheduled_task_add_contacts_from_chatrooms(self, redis_config, kafka_config, chatroom_member=await gewe_service.get_group_members_from_cache_async(wxid, chatroom_id) chatroom_nickname = chatroom.get('nickName') chatroom_owner_wxid = chatroom_member.get('chatroomOwner', None) - admin_wxids = chatroom_member.get('adminWxid', []) + admin_wxids = chatroom_member.get('adminWxid', []) + + admin_wxids = chatroom_member.get('adminWxid') + if admin_wxids is None: + admin_wxids = [] # 如果 admin_wxids 是 None,将其初始化为空列表 + logger.info(f'{chatroom_nickname} 的群主是 {chatroom_owner_wxid},管理员是{admin_wxids}') contact_wxids_set = set(contact_wxids) # for admin_wxid in admin_wxids: