Authored by hugufei

日志打印优化

@@ -106,23 +106,6 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -106,23 +106,6 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
106 List<RecallRequestResponse> batchRecallRequestResponses = batchRecallCacheBean.batchRecallAndCache(batchRecallRequests); 106 List<RecallRequestResponse> batchRecallRequestResponses = batchRecallCacheBean.batchRecallAndCache(batchRecallRequests);
107 RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallRequestResponses,cost is [{}]", System.currentTimeMillis() - begin); 107 RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallRequestResponses,cost is [{}]", System.currentTimeMillis() - begin);
108 108
109 - if(userRecallRequest.openDetailLog()){  
110 - for (RecallRequestResponse recallRequestResponse: batchRecallRequestResponses){  
111 - try {  
112 - RecallRequest recallRequest = recallRequestResponse.getRequest();  
113 - RecallResponse recallRespone = recallRequestResponse.getResponse();  
114 - if(recallRequest==null || recallRespone==null){  
115 - continue;  
116 - }  
117 - if(recallRespone.getSkns()==null || recallRespone.getSkns().isEmpty()){  
118 - RECALL_NEW_LOGGER.error("recall_type is [{}], dsl is [{}]",recallRequest.requestStrategy().name(), SearchParamUtils.genSearchSourceBuilderFromSearchParam(recallRequest.searchParam()).toString());  
119 - }  
120 - }catch (Exception e){  
121 -  
122 - }  
123 - }  
124 - }  
125 -  
126 //2、根据推荐的skn直接构造结果 109 //2、根据推荐的skn直接构造结果
127 List<RecallRequestResponse> recommendSknRequestResponses = this.buildRecommendSknRequestResponses(userPersonalFactor); 110 List<RecallRequestResponse> recommendSknRequestResponses = this.buildRecommendSknRequestResponses(userPersonalFactor);
128 111
@@ -134,22 +117,17 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us @@ -134,22 +117,17 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
134 //4、日志打印 117 //4、日志打印
135 if (userRecallRequest.openDetailLog()) { 118 if (userRecallRequest.openDetailLog()) {
136 for (RecallRequestResponse recallRequestResponse : batchRequestResults) { 119 for (RecallRequestResponse recallRequestResponse : batchRequestResults) {
137 - RECALL_NEW_LOGGER.info("request_type is [{}], response is [{}] ", recallRequestResponse.getRequest().requestStrategy().name(), this.getResponseLog(recallRequestResponse));  
138 - } 120 + RecallRequest recallRequest = recallRequestResponse.getRequest();
  121 + RecallResponse recallRespone = recallRequestResponse.getResponse();
  122 + StringBuilder responseValue = new StringBuilder();
  123 + responseValue.append( recallRespone==null?"null":JSON.toJSONString(recallRespone));
  124 + if(recallRespone!=null && (recallRespone.getSkns()==null || recallRespone.getSkns().isEmpty())){
  125 + responseValue.append(",dsl is [").append(SearchParamUtils.genSearchSourceBuilderFromSearchParam(recallRequest.searchParam()).toString());
139 } 126 }
140 - return batchRequestResults; 127 + RECALL_NEW_LOGGER.info("request_type is [{}], response is [{}] ", recallRequest.requestStrategy().name(),responseValue.toString());
141 } 128 }
142 -  
143 - private String getResponseLog(RecallRequestResponse recallRequestResponse) {  
144 - RecallResponse recallResponse = recallRequestResponse.getResponse();  
145 - StringBuilder responseLog = new StringBuilder();  
146 - if (recallResponse == null) {  
147 - responseLog.append("null");  
148 - } else {  
149 - responseLog.append("total is [").append(recallResponse.getTotal()).append("], ");  
150 - responseLog.append("sknList is ").append(recallResponse.getSkns() == null ? "[]" : JSON.toJSONString(recallResponse.getSkns()));  
151 } 129 }
152 - return responseLog.toString(); 130 + return batchRequestResults;
153 } 131 }
154 132
155 /** 133 /**