refactor: replace print() with structured logging across backend

Replace all print()/stderr logging with Python logging module using
logger = logging.getLogger(__name__) pattern for consistent log levels
and formatting. Extract score conversion to shared score_utils module.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 15:52:44 +08:00
parent 4bb50ae9c1
commit 37c0364e7e
19 changed files with 257 additions and 216 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
"""
LangChain 1.0 文档加载器封装 + PDF图片提取
"""
import logging
from typing import List, Optional, Dict
from pathlib import Path
import fitz # pymupdf
@@ -12,6 +13,8 @@ from langchain_community.document_loaders import (
)
from langchain_core.documents import Document
logger = logging.getLogger(__name__)
class PDFImageExtractor:
"""使用pymupdf从PDF中提取内嵌图片"""
@@ -59,7 +62,7 @@ class PDFImageExtractor:
"size": len(image_bytes),
})
except Exception as e:
print(f"[ImageExtractor] 提取图片失败 page={page_num+1} img={img_idx}: {e}")
logger.warning(f"提取图片失败 page={page_num+1} img={img_idx}: {e}")
continue
doc.close()