Authored by hugufei

日志打印优化

... ... @@ -106,23 +106,6 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
List<RecallRequestResponse> batchRecallRequestResponses = batchRecallCacheBean.batchRecallAndCache(batchRecallRequests);
RECALL_NEW_LOGGER.info("UserRecallRequestResponseCacheBean[2]-batchRecallRequestResponses,cost is [{}]", System.currentTimeMillis() - begin);
if(userRecallRequest.openDetailLog()){
for (RecallRequestResponse recallRequestResponse: batchRecallRequestResponses){
try {
RecallRequest recallRequest = recallRequestResponse.getRequest();
RecallResponse recallRespone = recallRequestResponse.getResponse();
if(recallRequest==null || recallRespone==null){
continue;
}
if(recallRespone.getSkns()==null || recallRespone.getSkns().isEmpty()){
RECALL_NEW_LOGGER.error("recall_type is [{}], dsl is [{}]",recallRequest.requestStrategy().name(), SearchParamUtils.genSearchSourceBuilderFromSearchParam(recallRequest.searchParam()).toString());
}
}catch (Exception e){
}
}
}
//2、根据推荐的skn直接构造结果
List<RecallRequestResponse> recommendSknRequestResponses = this.buildRecommendSknRequestResponses(userPersonalFactor);
... ... @@ -134,22 +117,17 @@ public class UserRecallCacheBean extends AbstractCacheBean<UserRecallRequest, Us
//4、日志打印
if (userRecallRequest.openDetailLog()) {
for (RecallRequestResponse recallRequestResponse : batchRequestResults) {
RECALL_NEW_LOGGER.info("request_type is [{}], response is [{}] ", recallRequestResponse.getRequest().requestStrategy().name(), this.getResponseLog(recallRequestResponse));
}
RecallRequest recallRequest = recallRequestResponse.getRequest();
RecallResponse recallRespone = recallRequestResponse.getResponse();
StringBuilder responseValue = new StringBuilder();
responseValue.append( recallRespone==null?"null":JSON.toJSONString(recallRespone));
if(recallRespone!=null && (recallRespone.getSkns()==null || recallRespone.getSkns().isEmpty())){
responseValue.append(",dsl is [").append(SearchParamUtils.genSearchSourceBuilderFromSearchParam(recallRequest.searchParam()).toString());
}
return batchRequestResults;
RECALL_NEW_LOGGER.info("request_type is [{}], response is [{}] ", recallRequest.requestStrategy().name(),responseValue.toString());
}
private String getResponseLog(RecallRequestResponse recallRequestResponse) {
RecallResponse recallResponse = recallRequestResponse.getResponse();
StringBuilder responseLog = new StringBuilder();
if (recallResponse == null) {
responseLog.append("null");
} else {
responseLog.append("total is [").append(recallResponse.getTotal()).append("], ");
responseLog.append("sknList is ").append(recallResponse.getSkns() == null ? "[]" : JSON.toJSONString(recallResponse.getSkns()));
}
return responseLog.toString();
return batchRequestResults;
}
/**
... ...