better 更好的logger格式
This commit is contained in:
@@ -154,7 +154,7 @@ class ChatBot:
|
||||
)
|
||||
# 开始思考的时间点
|
||||
thinking_time_point = round(time.time(), 2)
|
||||
logger.info(f"开始思考的时间点: {thinking_time_point}")
|
||||
# logger.debug(f"开始思考的时间点: {thinking_time_point}")
|
||||
think_id = "mt" + str(thinking_time_point)
|
||||
thinking_message = MessageThinking(
|
||||
message_id=think_id,
|
||||
|
||||
@@ -220,7 +220,7 @@ class MessageManager:
|
||||
|
||||
message_timeout = container.get_timeout_messages()
|
||||
if message_timeout:
|
||||
logger.warning(f"发现{len(message_timeout)}条超时消息")
|
||||
logger.debug(f"发现{len(message_timeout)}条超时消息")
|
||||
for msg in message_timeout:
|
||||
if msg == message_earliest:
|
||||
continue
|
||||
|
||||
@@ -76,18 +76,11 @@ def calculate_information_content(text):
|
||||
|
||||
|
||||
def get_closest_chat_from_db(length: int, timestamp: str):
|
||||
"""从数据库中获取最接近指定时间戳的聊天记录
|
||||
|
||||
Args:
|
||||
length: 要获取的消息数量
|
||||
timestamp: 时间戳
|
||||
|
||||
Returns:
|
||||
list: 消息记录列表,每个记录包含时间和文本信息
|
||||
"""
|
||||
# print(f"获取最接近指定时间戳的聊天记录,长度: {length}, 时间戳: {timestamp}")
|
||||
# print(f"当前时间: {timestamp},转换后时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp))}")
|
||||
chat_records = []
|
||||
closest_record = db.messages.find_one({"time": {"$lte": timestamp}}, sort=[("time", -1)])
|
||||
|
||||
# print(f"最接近的记录: {closest_record}")
|
||||
if closest_record:
|
||||
closest_time = closest_record["time"]
|
||||
chat_id = closest_record["chat_id"] # 获取chat_id
|
||||
@@ -102,7 +95,9 @@ def get_closest_chat_from_db(length: int, timestamp: str):
|
||||
.sort("time", 1)
|
||||
.limit(length)
|
||||
)
|
||||
|
||||
# print(f"获取到的记录: {chat_records}")
|
||||
length = len(chat_records)
|
||||
# print(f"获取到的记录长度: {length}")
|
||||
# 转换记录格式
|
||||
formatted_records = []
|
||||
for record in chat_records:
|
||||
|
||||
@@ -112,7 +112,7 @@ class ImageManager:
|
||||
# 查询缓存的描述
|
||||
cached_description = self._get_description_from_db(image_hash, "emoji")
|
||||
if cached_description:
|
||||
logger.info(f"缓存表情包描述: {cached_description}")
|
||||
logger.debug(f"缓存表情包描述: {cached_description}")
|
||||
return f"[表情包:{cached_description}]"
|
||||
|
||||
# 调用AI获取描述
|
||||
|
||||
Reference in New Issue
Block a user