From e9230b54211065a58ece87bd408fab9b180d483a Mon Sep 17 00:00:00 2001 From: jerryjzhang Date: Sat, 22 Jun 2024 12:59:41 +0800 Subject: [PATCH] (improvement)(headless)Reduce level of several logs, avoiding too verbase. --- README.md | 4 +- README_CN.md | 2 +- README_JP.md | 2 +- .../collection/trie/bintrie/BaseNode.java | 10 ++-- .../common/util/HttpClientUtils.java | 53 +++++++++---------- .../chat/mapper/BaseMatchStrategy.java | 2 +- .../query/rule/metric/MetricFilterQuery.java | 4 +- .../translator/DefaultSemanticTranslator.java | 6 +-- 8 files changed, 39 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index d7189ddf3..d1f48eba7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[中文介绍](README_CN.md) | [日本語版](README_JP.md) | [Docs](https://supersonicbi.github.io/) +[中文版](README_CN.md) | [日本語版](README_JP.md) | [Docs](https://supersonicbi.github.io/) ![Java CI](https://github.com/tencentmusic/supersonic/workflows/supersonic%20CI/badge.svg) @@ -58,7 +58,7 @@ The high-level architecture and main process flow is as follows: ### Online playground Visit http://117.72.46.148:9080 to register and experience as a new user. Please do not modify system configurations. We will restart to reset configurations regularly every weekend. -## Local build +### Local build SuperSonic comes with sample semantic models as well as chat conversations that can be used as a starting point. Please follow the steps: - Download the latest prebuilt binary from the [release page](https://github.com/tencentmusic/supersonic/releases) diff --git a/README_CN.md b/README_CN.md index 9f06308dd..0e8ba1e12 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,4 +1,4 @@ -[英文介绍](README.md) | [日本語版](README_JP.md) | [文档中心](https://supersonicbi.github.io/) +[English](README.md) | [日本語版](README_JP.md) | [文档中心](https://supersonicbi.github.io/) # SuperSonic diff --git a/README_JP.md b/README_JP.md index 6200b9551..f0b372a8b 100644 --- a/README_JP.md +++ b/README_JP.md @@ -56,7 +56,7 @@ ChatGPTのような大規模言語モデル(LLM)の出現は、情報検索 ### オンラインプレイグラウンド http://117.72.46.148:9080 にアクセスして、新規ユーザーとして登録して体験してください。システム設定を変更しないでください。毎週末に定期的に再起動して設定をリセットします。 -## ローカルビルド +### ローカルビルド SuperSonicには、サンプルのセマンティックモデルとチャット会話が付属しており、以下の手順で簡単に体験できます: - [リリースページ](https://github.com/tencentmusic/supersonic/releases)から最新のプリビルドバイナリをダウンロード diff --git a/common/src/main/java/com/hankcs/hanlp/collection/trie/bintrie/BaseNode.java b/common/src/main/java/com/hankcs/hanlp/collection/trie/bintrie/BaseNode.java index 53d61d033..e7b161db3 100644 --- a/common/src/main/java/com/hankcs/hanlp/collection/trie/bintrie/BaseNode.java +++ b/common/src/main/java/com/hankcs/hanlp/collection/trie/bintrie/BaseNode.java @@ -2,8 +2,7 @@ package com.hankcs.hanlp.collection.trie.bintrie; import com.hankcs.hanlp.LoadRemoveService; import com.hankcs.hanlp.corpus.io.ByteArray; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.io.DataOutputStream; import java.io.IOException; @@ -18,7 +17,7 @@ import java.util.Objects; import java.util.Queue; import java.util.Set; - +@Slf4j public abstract class BaseNode implements Comparable { /** @@ -26,7 +25,6 @@ public abstract class BaseNode implements Comparable { */ static final Status[] ARRAY_STATUS = Status.values(); - private static final Logger logger = LoggerFactory.getLogger(BaseNode.class); /** * 子节点 */ @@ -289,10 +287,10 @@ public abstract class BaseNode implements Comparable { public void walkNode(Set> entrySet) { if (status == Status.WORD_MIDDLE_2 || status == Status.WORD_END_3) { - logger.debug("walkNode before:{}", value.toString()); + log.debug("walkNode before:{}", value.toString()); List natures = new LoadRemoveService().removeNatures((List) value); String name = this.prefix != null ? this.prefix + c : "" + c; - logger.debug("walkNode name:{},after:{},natures:{}", name, (List) value, natures); + log.debug("walkNode name:{},after:{},natures:{}", name, (List) value, natures); entrySet.add(new TrieEntry(name, (V) natures)); } } diff --git a/common/src/main/java/com/tencent/supersonic/common/util/HttpClientUtils.java b/common/src/main/java/com/tencent/supersonic/common/util/HttpClientUtils.java index 6c1a6c36e..786dfb20d 100644 --- a/common/src/main/java/com/tencent/supersonic/common/util/HttpClientUtils.java +++ b/common/src/main/java/com/tencent/supersonic/common/util/HttpClientUtils.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -50,15 +52,10 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.CharsetUtils; import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; - +@Slf4j public class HttpClientUtils { - - private static final Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); - /*** * Encoding format. Unified sending encoding format using UTF-8 */ @@ -114,17 +111,17 @@ public class HttpClientUtils { HttpRequestRetryHandler httpRequestRetryHandler = (exception, executionCount, context) -> { // 如果已经重试了3次,就放弃 if (executionCount > 3) { - logger.warn("Maximum tries reached, exception would be thrown to outer block"); + log.warn("Maximum tries reached, exception would be thrown to outer block"); return false; } if (exception instanceof NoHttpResponseException) { // 如果服务器丢掉了连接,那么就重试 - logger.warn("Retry, No response from server on {} error: {}", executionCount, + log.warn("Retry, No response from server on {} error: {}", executionCount, exception.getMessage()); return true; } else if (exception instanceof SocketException) { // 如果服务器断开了连接,那么就重试 - logger.warn("Retry, No connection from server on {} error: {}", executionCount, + log.warn("Retry, No connection from server on {} error: {}", executionCount, exception.getMessage()); return true; } @@ -154,7 +151,7 @@ public class HttpClientUtils { .evictIdleConnections(5L, TimeUnit.SECONDS) .build(); } catch (Exception e) { - logger.error(e.getMessage(), e); + log.error(e.getMessage(), e); throw new RuntimeException(e); } } @@ -207,11 +204,11 @@ public class HttpClientUtils { response = httpClient.execute(httpPost); // 获取返回结果 HttpClientResult result = getHttpClientResult(response); - logger.info("uri:{}, req:{}, resp:{}", url, + log.info("uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpPost) + "------params:" + params, result); return result; } catch (Exception e) { - logger.error("uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); + log.error("uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); throw new RuntimeException(e.getMessage()); } finally { close(httpPost, response); @@ -288,11 +285,11 @@ public class HttpClientUtils { // 获取返回结果 HttpClientResult res = getHttpClientResult(response); - logger.debug("GET uri:{}, req:{}, resp:{}", url, + log.debug("GET uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpGet) + "------params:" + params, res); return res; } catch (Exception e) { - logger.error("GET error! uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); + log.error("GET error! uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); throw new RuntimeException(e.getMessage()); } finally { close(httpGet, response); @@ -320,12 +317,12 @@ public class HttpClientUtils { try { EntityUtils.consume(response.getEntity()); } catch (Throwable ex) { - logger.error("entity close error : ", ex); + log.error("entity close error : ", ex); } try { response.close(); } catch (Throwable ex) { - logger.error("response close error : ", ex); + log.error("response close error : ", ex); } } @@ -333,7 +330,7 @@ public class HttpClientUtils { try { httpRequest.abort(); } catch (Throwable ex) { - logger.error("httpPost abort error : ", ex); + log.error("httpPost abort error : ", ex); } } } @@ -433,11 +430,11 @@ public class HttpClientUtils { response = httpClient.execute(httpPost); // 获取返回结果 HttpClientResult res = getHttpClientResult(response); - logger.info("doPostJSON uri:{}, req:{}, resp:{}", url, + log.info("doPostJSON uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpPost) + "------req:" + req, res); return res; } catch (Exception e) { - logger.error("doPostJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); + log.error("doPostJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); throw new RuntimeException(e.getMessage()); } finally { close(httpPost, response); @@ -479,12 +476,12 @@ public class HttpClientUtils { // 获取返回结果 HttpClientResult res = getHttpClientResult(response); - logger.info("doGetJSON uri:{}, req:{}, resp:{}", url, + log.info("doGetJSON uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpGet) + "------params:" + params, res); return res; } catch (Exception e) { - logger.warn("doGetJSON error! uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); + log.warn("doGetJSON error! uri:{}, req:{}", url, "headers:" + headers + "------params:" + params, e); throw new RuntimeException(e.getMessage()); } finally { close(httpGet, response); @@ -548,11 +545,11 @@ public class HttpClientUtils { response = httpClient.execute(httpPost); // 执行请求并获得响应结果 HttpClientResult res = getHttpClientResult(response); - logger.info("doFileUpload uri:{}, req:{}, resp:{}", url, + log.info("doFileUpload uri:{}, req:{}, resp:{}", url, "params:" + params + ", fullFilePath:" + fullFilePath, res); return res; } catch (Exception e) { - logger.error("doFileUpload error! uri:{}, req:{}", url, + log.error("doFileUpload error! uri:{}, req:{}", url, "params:" + params + ", fullFilePath:" + fullFilePath, e); throw new RuntimeException(e.getMessage()); } finally { @@ -563,7 +560,7 @@ public class HttpClientUtils { // 释放资源 close(httpPost, response); } catch (IOException e) { - logger.error("HttpClientUtils release error!", e); + log.error("HttpClientUtils release error!", e); } } }); @@ -619,11 +616,11 @@ public class HttpClientUtils { response = httpClient.execute(httpDelete); HttpClientResult res = getHttpClientResult(response); - logger.info("doDeleteJSON uri:{}, req:{}, resp:{}", url, + log.info("doDeleteJSON uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpDelete) + "------req:" + req, res); return res; } catch (Exception e) { - logger.error("doDeleteJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); + log.error("doDeleteJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); throw new RuntimeException(e.getMessage()); } finally { close(httpDelete, response); @@ -671,11 +668,11 @@ public class HttpClientUtils { httpPut.setEntity(stringEntity); response = httpClient.execute(httpPut); HttpClientResult res = getHttpClientResult(response); - logger.info("doPutJSON uri:{}, req:{}, resp:{}", url, + log.info("doPutJSON uri:{}, req:{}, resp:{}", url, "headers:" + getHeaders(httpPut) + "------req:" + req, res); return res; } catch (Exception e) { - logger.error("doPutJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); + log.error("doPutJSON error! uri:{}, req:{}", url, "headers:" + headers + "------req:" + req, e); throw new RuntimeException(e.getMessage()); } finally { close(httpPut, response); diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java index a289ab0f9..461b621ba 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java @@ -136,7 +136,7 @@ public abstract class BaseMatchStrategy implements MatchStrategy { } return false; }).collect(Collectors.toList()); - log.info("terms filter by dataSetId:{}", dataSetIds); + log.debug("terms filter by dataSetId:{}", dataSetIds); logTerms(terms); } return terms; diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/query/rule/metric/MetricFilterQuery.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/query/rule/metric/MetricFilterQuery.java index 965e8bc20..ec9ed4fce 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/query/rule/metric/MetricFilterQuery.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/query/rule/metric/MetricFilterQuery.java @@ -70,7 +70,7 @@ public class MetricFilterQuery extends MetricSemanticQuery { private void addDimension(QueryStructReq queryStructReq, boolean onlyOperateInFilter) { if (!queryStructReq.getDimensionFilters().isEmpty()) { List dimensions = queryStructReq.getGroups(); - log.info("addDimension before [{}]", queryStructReq.getGroups()); + log.debug("addDimension before [{}]", queryStructReq.getGroups()); List filters = new ArrayList<>(queryStructReq.getDimensionFilters()); if (onlyOperateInFilter) { filters = filters.stream().filter(filter @@ -82,7 +82,7 @@ public class MetricFilterQuery extends MetricSemanticQuery { } }); queryStructReq.setGroups(dimensions); - log.info("addDimension after [{}]", queryStructReq.getGroups()); + log.debug("addDimension after [{}]", queryStructReq.getGroups()); } } diff --git a/headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/DefaultSemanticTranslator.java b/headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/DefaultSemanticTranslator.java index 1fe500b77..f8ee2f888 100644 --- a/headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/DefaultSemanticTranslator.java +++ b/headless/core/src/main/java/com/tencent/supersonic/headless/core/translator/DefaultSemanticTranslator.java @@ -52,7 +52,7 @@ public class DefaultSemanticTranslator implements SemanticTranslator { log.debug("SemanticConverter before [{}]", queryParam); for (QueryConverter headlessConverter : ComponentFactory.getQueryConverters()) { if (headlessConverter.accept(queryStatement)) { - log.info("SemanticConverter accept [{}]", headlessConverter.getClass().getName()); + log.debug("SemanticConverter accept [{}]", headlessConverter.getClass().getName()); headlessConverter.convert(queryStatement); } } @@ -76,7 +76,7 @@ public class DefaultSemanticTranslator implements SemanticTranslator { } public QueryStatement doParse(DataSetQueryParam dataSetQueryParam, QueryStatement queryStatement) { - log.info("parser MetricReq [{}] ", dataSetQueryParam); + log.info("parse dataSetQuery [{}] ", dataSetQueryParam); try { if (!CollectionUtils.isEmpty(dataSetQueryParam.getTables())) { List tables = new ArrayList<>(); @@ -123,7 +123,7 @@ public class DefaultSemanticTranslator implements SemanticTranslator { public QueryStatement doParse(QueryStatement queryStatement, AggOption isAgg) { MetricQueryParam metricQueryParam = queryStatement.getMetricQueryParam(); - log.info("parser metricQueryReq [{}] isAgg [{}]", metricQueryParam, isAgg); + log.info("parse metricQuery [{}] isAgg [{}]", metricQueryParam, isAgg); try { ComponentFactory.getQueryParser().parse(queryStatement, isAgg); } catch (Exception e) {