mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
feat(connection): 增加日志记录功能
- 在 connection.py 和 receiveAudioHandle.py 中添加了日志记录功能 - 记录设备 ID、时间戳和模型回复/用户输入的文本 - 优化了日志格式,使其包含更多有用信息
This commit is contained in:
parent
1bbcb19a52
commit
03cc7318f8
2 changed files with 6 additions and 4 deletions
|
|
@ -27,9 +27,9 @@ from config.private_config import PrivateConfig
|
|||
from core.auth import AuthMiddleware, AuthenticationError
|
||||
from core.utils.auth_code_gen import AuthCodeGenerator
|
||||
from core.mcp.manager import MCPManager
|
||||
|
||||
from datetime import datetime
|
||||
TAG = __name__
|
||||
|
||||
logger = setup_logging()
|
||||
auto_import_modules("plugins_func.functions")
|
||||
|
||||
|
||||
|
|
@ -370,6 +370,8 @@ class ConnectionHandler:
|
|||
|
||||
# 处理最后剩余的文本
|
||||
full_text = "".join(response_message)
|
||||
|
||||
logger.bind(tag=TAG).info(f"deviceId: {self.conn.private_config.device_id},datetime: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")},模型回复: {full_text}")
|
||||
remaining_text = full_text[processed_chars:]
|
||||
if remaining_text:
|
||||
segment_text = get_string_no_punctuation_or_emoji(remaining_text)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import time
|
|||
from core.utils.util import remove_punctuation_and_length
|
||||
from core.handle.sendAudioHandle import send_stt_message
|
||||
from core.handle.intentHandler import handle_user_intent
|
||||
|
||||
from datetime import datetime
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ async def handleAudioMessage(conn, audio):
|
|||
text, file_path = await conn.asr.speech_to_text(
|
||||
conn.asr_audio, conn.session_id
|
||||
)
|
||||
logger.bind(tag=TAG).info(f"识别文本: {text}")
|
||||
logger.bind(tag=TAG).info(f"deviceId: {conn.private_config.device_id},datetime: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")},用户说: {text}")
|
||||
text_len, _ = remove_punctuation_and_length(text)
|
||||
if text_len > 0:
|
||||
await startToChat(conn, text)
|
||||
|
|
|
|||
Loading…
Reference in a new issue