Эх сурвалжийг харах

chore: 添加位置映射调试日志

帮助诊断 position 补充流程
何文松 1 сар өмнө
parent
commit
90e9c89a50

+ 4 - 0
backend/graph-service/src/main/java/com/lingyue/graph/service/GraphNerService.java

@@ -305,6 +305,7 @@ public class GraphNerService {
         // 如果已经有页码和行号,直接返回
         if (posMap.containsKey("page") && posMap.get("page") != null 
             && posMap.containsKey("line") && posMap.get("line") != null) {
+            log.debug("位置信息已完整,跳过映射: documentId={}", documentId);
             return posMap;
         }
         
@@ -313,11 +314,13 @@ public class GraphNerService {
         Integer charEnd = getIntValue(posMap, "charEnd");
         
         if (charStart == null || charEnd == null) {
+            log.debug("缺少字符位置信息,跳过映射: documentId={}, posMap={}", documentId, posMap);
             return posMap;
         }
         
         try {
             // 使用 PositionMappingService 映射页码和行号
+            log.debug("开始位置映射: documentId={}, charStart={}, charEnd={}", documentId, charStart, charEnd);
             Map<String, Object> mappedPosition = positionMappingService.mapCharToPosition(
                 documentId, charStart, charEnd);
             
@@ -325,6 +328,7 @@ public class GraphNerService {
             Map<String, Object> enrichedPosition = new HashMap<>(posMap);
             enrichedPosition.putAll(mappedPosition);
             
+            log.debug("位置映射完成: documentId={}, result={}", documentId, enrichedPosition);
             return enrichedPosition;
         } catch (Exception e) {
             log.warn("位置映射失败: documentId={}, charStart={}, charEnd={}, error={}", 

+ 4 - 1
backend/graph-service/src/main/java/com/lingyue/graph/service/PositionMappingService.java

@@ -168,6 +168,7 @@ public class PositionMappingService {
     private DocumentIndex loadDocumentIndex(String documentId) {
         // 先检查缓存
         if (indexCache.containsKey(documentId)) {
+            log.debug("从缓存加载索引: documentId={}", documentId);
             return indexCache.get(documentId);
         }
         
@@ -175,8 +176,10 @@ public class PositionMappingService {
         String indexFilePath = buildIndexFilePath(documentId);
         Path path = Path.of(indexFilePath);
         
+        log.debug("尝试加载索引文件: {}", indexFilePath);
+        
         if (!Files.exists(path)) {
-            log.debug("索引文件不存在: {}", indexFilePath);
+            log.info("索引文件不存在,无法补充页码信息: {}", indexFilePath);
             return null;
         }