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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user