You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/10/10 02:59:48 UTC
[shenyu] branch master updated: [type:refactor] refactor log module (#4062)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new cc2a06c6e [type:refactor] refactor log module (#4062)
cc2a06c6e is described below
commit cc2a06c6ea76299ef6527c2f5dcd433e61654df3
Author: moremind <he...@hotmail.com>
AuthorDate: Mon Oct 10 10:59:40 2022 +0800
[type:refactor] refactor log module (#4062)
* refactor log module
* refactor log module
* refactor log module
* refactor log module
* refactor log module
* fix check style
* fix check style
* fix check style
* fix check style
---
.../plugin/aliyun/sls/LoggingAliyunSlsPlugin.java | 22 +++++++-
.../sls/client/AliyunSlsLogCollectClient.java | 2 +-
.../sls/collector/AliyunSlsLogCollector.java | 12 +++-
.../clickhouse/LoggingClickHousePlugin.java | 23 +++++++-
.../client/ClickHouseLogCollectClient.java | 2 +-
.../collector/ClickHouseLogCollector.java | 12 +++-
.../logging/common/AbstractLoggingPlugin.java | 22 ++++++--
.../common/body/LoggingServerHttpRequest.java | 6 +-
.../common/body/LoggingServerHttpResponse.java | 65 +++++-----------------
.../common/client/AbstractLogConsumeClient.java | 7 ++-
.../logging/common/client/LogConsumeClient.java | 4 +-
.../common/collector/AbstractLogCollector.java | 63 +++++++++++++++++++--
.../logging/common/collector/LogCollector.java | 14 ++++-
.../logging/console/LoggingConsolePlugin.java | 6 +-
.../elasticsearch/LoggingElasticSearchPlugin.java | 22 +++++++-
.../client/ElasticSearchLogCollectClient.java | 2 +-
.../collector/ElasticSearchLogCollector.java | 12 +++-
.../plugin/logging/kafka/LoggingKafkaPlugin.java | 22 +++++++-
.../kafka/client/KafkaLogCollectClient.java | 2 +-
.../logging/kafka/collector/KafkaLogCollector.java | 12 +++-
.../mask/{ => api}/enums/DataMaskEnums.java | 2 +-
.../mask/{ => api}/factory/DataMaskFactory.java | 4 +-
.../mask/{ => api}/matcher/KeyWordMatch.java | 2 +-
.../mask/{ => api}/spi/AbstractShenyuDataMask.java | 2 +-
.../{ => api}/spi/CharacterReplaceDataMask.java | 2 +-
.../mask/{ => api}/spi/Md5EncryptDataMask.java | 2 +-
.../logging/mask/{ => api}/spi/ShenyuDataMask.java | 2 +-
.../mask/{ => api}/utils/DataMaskUtils.java | 32 ++++++++++-
...nyu.plugin.logging.mask.api.spi.ShenyuDataMask} | 4 +-
.../{ => api}/factory/DataMaskFactoryTest.java | 4 +-
.../mask/{ => api}/matcher/KeyWordMatchTest.java | 2 +-
.../spi/CharacterReplaceDataMaskTest.java | 6 +-
.../mask/{ => api}/spi/Md5EncryptDataMaskTest.java | 2 +-
.../mask/{ => api}/utils/DataMaskUtilsTest.java | 6 +-
.../plugin/logging/pulsar/LoggingPulsarPlugin.java | 22 +++++++-
.../pulsar/client/PulsarLogCollectClient.java | 2 +-
.../pulsar/collector/PulsarLogCollector.java | 12 +++-
.../logging/rocketmq/LoggingRocketMQPlugin.java | 22 +++++++-
.../rocketmq/client/RocketMQLogCollectClient.java | 2 +-
.../rocketmq/collector/RocketMQLogCollector.java | 12 +++-
.../tencent/cls/LoggingTencentClsPlugin.java | 22 +++++++-
.../cls/client/TencentClsLogCollectClient.java | 2 +-
.../cls/collector/TencentClsSlsLogCollector.java | 12 +++-
43 files changed, 371 insertions(+), 141 deletions(-)
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/LoggingAliyunSlsPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/LoggingAliyunSlsPlugin.java
index bd9ceaeb2..969a48168 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/LoggingAliyunSlsPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/LoggingAliyunSlsPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.aliyun.sls;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.aliyun.sls.collector.AliyunSlsLogCollector;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.springframework.web.server.ServerWebExchange;
/**
* LoggingAliYunSlsPlugin send log to aliyun sls service.
*/
-public class LoggingAliyunSlsPlugin extends AbstractLoggingPlugin {
+public class LoggingAliyunSlsPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return AliyunSlsLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingAliyunSlsPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_ALIYUN_SLS;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog's class
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/client/AliyunSlsLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/client/AliyunSlsLogCollectClient.java
index feb6cb3b9..ae9fb78e9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/client/AliyunSlsLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/client/AliyunSlsLogCollectClient.java
@@ -54,7 +54,7 @@ import java.util.concurrent.TimeUnit;
/**
* Aliyun sls log Collect client.
*/
-public class AliyunSlsLogCollectClient extends AbstractLogConsumeClient<AliyunLogCollectConfig.AliyunSlsLogConfig> {
+public class AliyunSlsLogCollectClient extends AbstractLogConsumeClient<AliyunLogCollectConfig.AliyunSlsLogConfig, ShenyuRequestLog> {
private Client client;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/collector/AliyunSlsLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/collector/AliyunSlsLogCollector.java
index eb45af10d..c9011c28e 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/collector/AliyunSlsLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-aliyun-sls/src/main/java/org/apache/shenyu/plugin/aliyun/sls/collector/AliyunSlsLogCollector.java
@@ -21,20 +21,22 @@ import org.apache.shenyu.plugin.aliyun.sls.client.AliyunSlsLogCollectClient;
import org.apache.shenyu.plugin.aliyun.sls.handler.LoggingAliyunSlsPluginDataHandler;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
/**
* aliyun sls log collector,depend a LogConsumeClient for consume logs.
*/
-public class AliyunSlsLogCollector extends AbstractLogCollector<AliyunSlsLogCollectClient> {
+public class AliyunSlsLogCollector extends AbstractLogCollector<AliyunSlsLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new AliyunSlsLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new AliyunSlsLogCollector();
/**
* get LogCollector instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -42,4 +44,8 @@ public class AliyunSlsLogCollector extends AbstractLogCollector<AliyunSlsLogColl
protected AliyunSlsLogCollectClient getLogConsumeClient() {
return LoggingAliyunSlsPluginDataHandler.getAliyunSlsLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
index 11d3f10d0..d9934f0f4 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.logging.clickhouse;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.clickhouse.collector.ClickHouseLogCollector;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.springframework.web.server.ServerWebExchange;
/**
* LoggingClickHousePlugin.
*/
-public class LoggingClickHousePlugin extends AbstractLoggingPlugin {
+public class LoggingClickHousePlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return ClickHouseLogCollector.getInstance();
}
@@ -41,4 +45,19 @@ public class LoggingClickHousePlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_CLICK_HOUSE;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
+
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
index f457c3b08..d4c91e2a9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
@@ -43,7 +43,7 @@ import java.util.TimeZone;
/**
* queue-based logging collector.
*/
-public class ClickHouseLogCollectClient extends AbstractLogConsumeClient<ClickHouseLogCollectConfig.ClickHouseLogConfig> {
+public class ClickHouseLogCollectClient extends AbstractLogConsumeClient<ClickHouseLogCollectConfig.ClickHouseLogConfig, ShenyuRequestLog> {
private ClickHouseClient client;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
index 8545a73a6..6018c7369 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
@@ -21,17 +21,19 @@ import org.apache.shenyu.plugin.logging.clickhouse.client.ClickHouseLogCollectCl
import org.apache.shenyu.plugin.logging.clickhouse.handler.LoggingClickHousePluginDataHandler;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
-public class ClickHouseLogCollector extends AbstractLogCollector<ClickHouseLogCollectClient> {
+public class ClickHouseLogCollector extends AbstractLogCollector<ClickHouseLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new ClickHouseLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new ClickHouseLogCollector();
/**
* get LogCollector Instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -39,4 +41,8 @@ public class ClickHouseLogCollector extends AbstractLogCollector<ClickHouseLogCo
protected ClickHouseLogCollectClient getLogConsumeClient() {
return LoggingClickHousePluginDataHandler.getClickHouseLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/AbstractLoggingPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/AbstractLoggingPlugin.java
index b2ea44b04..3c190e3f9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/AbstractLoggingPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/AbstractLoggingPlugin.java
@@ -34,7 +34,7 @@ import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler;
import org.apache.shenyu.plugin.logging.common.utils.LogCollectConfigUtils;
import org.apache.shenyu.plugin.logging.common.utils.LogCollectUtils;
-import org.apache.shenyu.plugin.logging.mask.enums.DataMaskEnums;
+import org.apache.shenyu.plugin.logging.mask.api.enums.DataMaskEnums;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -51,7 +51,7 @@ import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
/**
* abstract logging plugin.
*/
-public abstract class AbstractLoggingPlugin extends AbstractShenyuPlugin {
+public abstract class AbstractLoggingPlugin<L extends ShenyuRequestLog> extends AbstractShenyuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(AbstractLoggingPlugin.class);
@@ -62,7 +62,7 @@ public abstract class AbstractLoggingPlugin extends AbstractShenyuPlugin {
*
* @return LogCollector
*/
- protected abstract LogCollector logCollector();
+ protected abstract LogCollector<L> logCollector();
/**
* pluginEnum.
@@ -71,6 +71,16 @@ public abstract class AbstractLoggingPlugin extends AbstractShenyuPlugin {
*/
protected abstract PluginEnum pluginEnum();
+ /**
+ * collect log based on ShenyuRequestLog.
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return based on ShenyuRequestLog
+ */
+ protected abstract L doLogExecute(ServerWebExchange exchange, SelectorData selector, RuleData rule);
+
@Override
public Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain,
final SelectorData selector, final RuleData rule) {
@@ -91,7 +101,7 @@ public abstract class AbstractLoggingPlugin extends AbstractShenyuPlugin {
if (!LogCollectConfigUtils.isSampled(exchange.getRequest())) {
return chain.execute(exchange);
}
- ShenyuRequestLog requestInfo = new ShenyuRequestLog();
+ L requestInfo = this.doLogExecute(exchange, selector, rule);
requestInfo.setRequestUri(request.getURI().toString());
requestInfo.setMethod(request.getMethodValue());
requestInfo.setRequestHeader(LogCollectUtils.getHeaders(request.getHeaders()));
@@ -100,8 +110,8 @@ public abstract class AbstractLoggingPlugin extends AbstractShenyuPlugin {
requestInfo.setUserAgent(request.getHeaders().getFirst(GenericLoggingConstant.USER_AGENT));
requestInfo.setHost(request.getHeaders().getFirst(GenericLoggingConstant.HOST));
requestInfo.setPath(request.getURI().getPath());
- LoggingServerHttpRequest loggingServerHttpRequest = new LoggingServerHttpRequest(request, requestInfo);
- LoggingServerHttpResponse loggingServerHttpResponse = new LoggingServerHttpResponse(exchange.getResponse(),
+ LoggingServerHttpRequest<L> loggingServerHttpRequest = new LoggingServerHttpRequest<>(request, requestInfo);
+ LoggingServerHttpResponse<L> loggingServerHttpResponse = new LoggingServerHttpResponse<>(exchange.getResponse(),
requestInfo, this.logCollector(), masked, keywordSets, dataMaskAlg);
ServerWebExchange webExchange = exchange.mutate().request(loggingServerHttpRequest)
.response(loggingServerHttpResponse).build();
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpRequest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpRequest.java
index bb4d80f46..723f5911c 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpRequest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpRequest.java
@@ -29,11 +29,11 @@ import reactor.util.annotation.NonNull;
/**
* decorate ServerHttpRequest for read body.
*/
-public class LoggingServerHttpRequest extends ServerHttpRequestDecorator {
+public class LoggingServerHttpRequest<L extends ShenyuRequestLog> extends ServerHttpRequestDecorator {
- private final ShenyuRequestLog logInfo;
+ private final L logInfo;
- public LoggingServerHttpRequest(final ServerHttpRequest delegate, final ShenyuRequestLog logInfo) {
+ public LoggingServerHttpRequest(final ServerHttpRequest delegate, final L logInfo) {
super(delegate);
this.logInfo = logInfo;
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpResponse.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpResponse.java
index 8e70113c8..cbacd6d9b 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpResponse.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpResponse.java
@@ -26,11 +26,10 @@ import org.apache.shenyu.plugin.api.result.ShenyuResult;
import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
-import org.apache.shenyu.plugin.logging.mask.matcher.KeyWordMatch;
import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
-import org.apache.shenyu.plugin.logging.mask.utils.DataMaskUtils;
import org.apache.shenyu.plugin.logging.common.utils.LogCollectConfigUtils;
import org.apache.shenyu.plugin.logging.common.utils.LogCollectUtils;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,17 +55,17 @@ import java.util.Set;
/**
* decorate ServerHttpResponse for read body.
*/
-public class LoggingServerHttpResponse extends ServerHttpResponseDecorator {
+public class LoggingServerHttpResponse<L extends ShenyuRequestLog> extends ServerHttpResponseDecorator {
private static final Logger LOG = LoggerFactory.getLogger(LoggingServerHttpResponse.class);
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
- private final ShenyuRequestLog logInfo;
+ private final L logInfo;
private ServerWebExchange exchange;
- private final LogCollector logCollector;
+ private final LogCollector<L> logCollector;
private final boolean maskFlag;
@@ -84,8 +83,8 @@ public class LoggingServerHttpResponse extends ServerHttpResponseDecorator {
* @param keyWordSet user keyWord set
* @param dataMaskAlg mask function
*/
- public LoggingServerHttpResponse(final ServerHttpResponse delegate, final ShenyuRequestLog logInfo,
- final LogCollector logCollector, final boolean maskFlag,
+ public LoggingServerHttpResponse(final ServerHttpResponse delegate, final L logInfo,
+ final LogCollector<L> logCollector, final boolean maskFlag,
final Set<String> keyWordSet, final String dataMaskAlg) {
super(delegate);
this.logInfo = logInfo;
@@ -166,11 +165,12 @@ public class LoggingServerHttpResponse extends ServerHttpResponseDecorator {
if (size > 0 && !LogCollectConfigUtils.isResponseBodyTooLarge(size)) {
logInfo.setResponseBody(body);
}
- if (maskFlag) {
- this.mask(logInfo);
- }
// collect log
if (Objects.nonNull(logCollector)) {
+ // mask log
+ if (maskFlag) {
+ logCollector.mask(logInfo, keyWordMatch, dataMaskAlg);
+ }
logCollector.collect(logInfo);
}
}
@@ -251,11 +251,12 @@ public class LoggingServerHttpResponse extends ServerHttpResponseDecorator {
if (size > 0 && !LogCollectConfigUtils.isResponseBodyTooLarge(size)) {
logInfo.setResponseBody(body);
}
- if (maskFlag) {
- this.mask(logInfo);
- }
// collect log
if (Objects.nonNull(logCollector)) {
+ // mask log
+ if (maskFlag) {
+ logCollector.mask(logInfo, keyWordMatch, dataMaskAlg);
+ }
logCollector.collect(logInfo);
}
}
@@ -272,42 +273,4 @@ public class LoggingServerHttpResponse extends ServerHttpResponseDecorator {
}
return "";
}
-
- private void mask(final ShenyuRequestLog logInfo) {
- logInfo.setClientIp(maskForSingle(GenericLoggingConstant.CLIENT_IP, logInfo.getClientIp()));
- logInfo.setTimeLocal(maskForSingle(GenericLoggingConstant.TIME_LOCAL, logInfo.getTimeLocal()));
- logInfo.setMethod(maskForSingle(GenericLoggingConstant.METHOD, logInfo.getMethod()));
- logInfo.setRequestUri(maskForSingle(GenericLoggingConstant.REQUEST_URI, logInfo.getRequestUri()));
- logInfo.setResponseContentLength(Integer.valueOf(maskForSingle(GenericLoggingConstant.RESPONSE_CONTENT_LENGTH,
- logInfo.getResponseContentLength().toString())));
- logInfo.setRpcType(maskForSingle(GenericLoggingConstant.RPC_TYPE, logInfo.getRpcType()));
- logInfo.setStatus(Integer.valueOf(maskForSingle(GenericLoggingConstant.STATUS, logInfo.getStatus().toString())));
- logInfo.setUpstreamIp(maskForSingle(GenericLoggingConstant.UP_STREAM_IP, logInfo.getUpstreamIp()));
- logInfo.setUpstreamResponseTime(Long.valueOf(maskForSingle(GenericLoggingConstant.UP_STREAM_RESPONSE_TIME,
- logInfo.getUpstreamResponseTime().toString())));
- logInfo.setUserAgent(maskForSingle(GenericLoggingConstant.USERAGENT, logInfo.getUserAgent()));
- logInfo.setHost(maskForSingle(GenericLoggingConstant.HOST, logInfo.getHost()));
- logInfo.setModule(maskForSingle(GenericLoggingConstant.MODULE, logInfo.getModule()));
- logInfo.setTraceId(maskForSingle(GenericLoggingConstant.TRACE_ID, logInfo.getTraceId()));
- logInfo.setPath(maskForSingle(GenericLoggingConstant.PATH, logInfo.getPath()));
- logInfo.setRequestHeader(maskForSingle(GenericLoggingConstant.REQUEST_HEADER, logInfo.getRequestHeader()));
- logInfo.setResponseHeader(maskForSingle(GenericLoggingConstant.RESPONSE_HEADER,
- logInfo.getResponseHeader()));
- logInfo.setQueryParams(maskForSingle(GenericLoggingConstant.QUERY_PARAMS, logInfo.getQueryParams()));
- logInfo.setRequestBody(maskForSingle(GenericLoggingConstant.REQUEST_BODY, logInfo.getRequestBody()));
- logInfo.setResponseBody(maskForSingle(GenericLoggingConstant.RESPONSE_BODY, logInfo.getResponseBody()));
- logInfo.setRequestHeader(maskForBody(logInfo.getRequestHeader()));
- logInfo.setResponseHeader(maskForBody(logInfo.getResponseHeader()));
- logInfo.setQueryParams(maskForBody(logInfo.getQueryParams()));
- logInfo.setRequestBody(maskForBody(logInfo.getRequestBody()));
- logInfo.setResponseBody(maskForBody(logInfo.getResponseBody()));
- }
-
- private String maskForSingle(final String keyWord, final String val) {
- return DataMaskUtils.maskSingleKeyword(maskFlag, keyWord, val, keyWordMatch, dataMaskAlg);
- }
-
- private String maskForBody(final String body) {
- return DataMaskUtils.maskBody(maskFlag, body, keyWordMatch, dataMaskAlg);
- }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/AbstractLogConsumeClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/AbstractLogConsumeClient.java
index a5cc136e5..aba6fb6ed 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/AbstractLogConsumeClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/AbstractLogConsumeClient.java
@@ -32,7 +32,8 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* AbstractLogConsumeClient.
*/
-public abstract class AbstractLogConsumeClient<T extends GenericGlobalConfig> implements LogConsumeClient<T> {
+public abstract class AbstractLogConsumeClient<T extends GenericGlobalConfig, L extends ShenyuRequestLog>
+ implements LogConsumeClient<T, L> {
protected static final Logger LOG = LoggerFactory.getLogger(AbstractLogConsumeClient.class);
@@ -53,7 +54,7 @@ public abstract class AbstractLogConsumeClient<T extends GenericGlobalConfig> im
* @param logs logs
* @throws Exception error
*/
- public abstract void consume0(@NonNull List<ShenyuRequestLog> logs) throws Exception;
+ public abstract void consume0(@NonNull List<L> logs) throws Exception;
/**
* close0.
@@ -93,7 +94,7 @@ public abstract class AbstractLogConsumeClient<T extends GenericGlobalConfig> im
}
@Override
- public void consume(final List<ShenyuRequestLog> logs) throws Exception {
+ public void consume(final List<L> logs) throws Exception {
if (CollectionUtils.isEmpty(logs) || !isStarted.get()) {
return;
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/LogConsumeClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/LogConsumeClient.java
index aeee90645..6722e199f 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/LogConsumeClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/LogConsumeClient.java
@@ -25,7 +25,7 @@ import java.util.List;
/**
* Used to collect logs, which can be stored in remote or local files or databases, or others.
*/
-public interface LogConsumeClient<C extends GenericGlobalConfig> extends AutoCloseable {
+public interface LogConsumeClient<C extends GenericGlobalConfig, L extends ShenyuRequestLog> extends AutoCloseable {
/**
* collect logs.
@@ -33,7 +33,7 @@ public interface LogConsumeClient<C extends GenericGlobalConfig> extends AutoClo
* @param logs list of log
* @throws Exception produce exception
*/
- void consume(List<ShenyuRequestLog> logs) throws Exception;
+ void consume(List<L> logs) throws Exception;
/**
* init client by config.
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/AbstractLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/AbstractLogCollector.java
index 89ed8e4f9..5f443d5f6 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/AbstractLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/AbstractLogCollector.java
@@ -25,8 +25,10 @@ import org.apache.shenyu.common.constant.Constants;
import org.apache.shenyu.common.utils.Singleton;
import org.apache.shenyu.common.utils.ThreadUtils;
import org.apache.shenyu.plugin.logging.common.client.AbstractLogConsumeClient;
+import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.common.utils.LogCollectConfigUtils;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,16 +42,20 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.apache.shenyu.plugin.logging.mask.api.utils.DataMaskUtils.maskForBody;
+import static org.apache.shenyu.plugin.logging.mask.api.utils.DataMaskUtils.maskForSingleWord;
+
/**
* abstract log collector,Contains common methods.
*/
-public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>> implements LogCollector {
+public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?, L>, L extends ShenyuRequestLog>
+ implements LogCollector<L> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractLogCollector.class);
private int bufferSize;
- private BlockingQueue<ShenyuRequestLog> bufferQueue;
+ private BlockingQueue<L> bufferQueue;
private long lastPushTime;
@@ -71,7 +77,7 @@ public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>
}
@Override
- public void collect(final ShenyuRequestLog log) {
+ public void collect(final L log) {
if (Objects.isNull(log) || Objects.isNull(getLogConsumeClient())) {
return;
}
@@ -80,6 +86,12 @@ public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>
}
}
+ @Override
+ public void mask(final L logInfo, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ this.maskShenyuRequestLog(logInfo, keyWordMatch, dataMaskAlg);
+ this.maskLog(logInfo, keyWordMatch, dataMaskAlg);
+ }
+
/**
* batch and async consume.
*/
@@ -87,14 +99,14 @@ public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>
while (started.get()) {
int diffTimeMSForPush = 100;
try {
- List<ShenyuRequestLog> logs = new ArrayList<>();
+ List<L> logs = new ArrayList<>();
int size = bufferQueue.size();
long time = System.currentTimeMillis();
long timeDiffMs = time - lastPushTime;
int batchSize = 100;
if (size >= batchSize || timeDiffMs > diffTimeMSForPush) {
bufferQueue.drainTo(logs, batchSize);
- AbstractLogConsumeClient<?> logCollectClient = getLogConsumeClient();
+ AbstractLogConsumeClient<?, L> logCollectClient = getLogConsumeClient();
if (Objects.nonNull(logCollectClient)) {
logCollectClient.consume(logs);
}
@@ -109,6 +121,36 @@ public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>
}
}
+ private void maskShenyuRequestLog(final L logInfo, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ logInfo.setClientIp(maskForSingleWord(GenericLoggingConstant.CLIENT_IP, logInfo.getClientIp(), keyWordMatch, dataMaskAlg));
+ logInfo.setTimeLocal(maskForSingleWord(GenericLoggingConstant.TIME_LOCAL, logInfo.getTimeLocal(), keyWordMatch, dataMaskAlg));
+ logInfo.setMethod(maskForSingleWord(GenericLoggingConstant.METHOD, logInfo.getMethod(), keyWordMatch, dataMaskAlg));
+ logInfo.setRequestUri(maskForSingleWord(GenericLoggingConstant.REQUEST_URI, logInfo.getRequestUri(), keyWordMatch, dataMaskAlg));
+ logInfo.setResponseContentLength(Integer.valueOf(maskForSingleWord(GenericLoggingConstant.RESPONSE_CONTENT_LENGTH,
+ logInfo.getResponseContentLength().toString(), keyWordMatch, dataMaskAlg)));
+ logInfo.setRpcType(maskForSingleWord(GenericLoggingConstant.RPC_TYPE, logInfo.getRpcType(), keyWordMatch, dataMaskAlg));
+ logInfo.setStatus(Integer.valueOf(maskForSingleWord(GenericLoggingConstant.STATUS, logInfo.getStatus().toString(), keyWordMatch, dataMaskAlg)));
+ logInfo.setUpstreamIp(maskForSingleWord(GenericLoggingConstant.UP_STREAM_IP, logInfo.getUpstreamIp(), keyWordMatch, dataMaskAlg));
+ logInfo.setUpstreamResponseTime(Long.valueOf(maskForSingleWord(GenericLoggingConstant.UP_STREAM_RESPONSE_TIME,
+ logInfo.getUpstreamResponseTime().toString(), keyWordMatch, dataMaskAlg)));
+ logInfo.setUserAgent(maskForSingleWord(GenericLoggingConstant.USERAGENT, logInfo.getUserAgent(), keyWordMatch, dataMaskAlg));
+ logInfo.setHost(maskForSingleWord(GenericLoggingConstant.HOST, logInfo.getHost(), keyWordMatch, dataMaskAlg));
+ logInfo.setModule(maskForSingleWord(GenericLoggingConstant.MODULE, logInfo.getModule(), keyWordMatch, dataMaskAlg));
+ logInfo.setTraceId(maskForSingleWord(GenericLoggingConstant.TRACE_ID, logInfo.getTraceId(), keyWordMatch, dataMaskAlg));
+ logInfo.setPath(maskForSingleWord(GenericLoggingConstant.PATH, logInfo.getPath(), keyWordMatch, dataMaskAlg));
+ logInfo.setRequestHeader(maskForSingleWord(GenericLoggingConstant.REQUEST_HEADER, logInfo.getRequestHeader(), keyWordMatch, dataMaskAlg));
+ logInfo.setResponseHeader(maskForSingleWord(GenericLoggingConstant.RESPONSE_HEADER, logInfo.getResponseHeader(),
+ keyWordMatch, dataMaskAlg));
+ logInfo.setQueryParams(maskForSingleWord(GenericLoggingConstant.QUERY_PARAMS, logInfo.getQueryParams(), keyWordMatch, dataMaskAlg));
+ logInfo.setRequestBody(maskForSingleWord(GenericLoggingConstant.REQUEST_BODY, logInfo.getRequestBody(), keyWordMatch, dataMaskAlg));
+ logInfo.setResponseBody(maskForSingleWord(GenericLoggingConstant.RESPONSE_BODY, logInfo.getResponseBody(), keyWordMatch, dataMaskAlg));
+ logInfo.setRequestHeader(maskForBody(logInfo.getRequestHeader(), keyWordMatch, dataMaskAlg));
+ logInfo.setResponseHeader(maskForBody(logInfo.getResponseHeader(), keyWordMatch, dataMaskAlg));
+ logInfo.setQueryParams(maskForBody(logInfo.getQueryParams(), keyWordMatch, dataMaskAlg));
+ logInfo.setRequestBody(maskForBody(logInfo.getRequestBody(), keyWordMatch, dataMaskAlg));
+ logInfo.setResponseBody(maskForBody(logInfo.getResponseBody(), keyWordMatch, dataMaskAlg));
+ }
+
/**
* get log consume client.
*
@@ -116,10 +158,19 @@ public abstract class AbstractLogCollector<T extends AbstractLogConsumeClient<?>
*/
protected abstract T getLogConsumeClient();
+ /**
+ * mask log.
+ *
+ * @param log log
+ * @param keyWordMatch keyWordMathc
+ * @param dataMaskAlg data mask algorithm
+ */
+ protected abstract void maskLog(L log, KeyWordMatch keyWordMatch, String dataMaskAlg);
+
@Override
public void close() throws Exception {
started.set(false);
- AbstractLogConsumeClient<?> logCollectClient = getLogConsumeClient();
+ AbstractLogConsumeClient<?, ?> logCollectClient = getLogConsumeClient();
if (logCollectClient != null) {
logCollectClient.close();
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/LogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/LogCollector.java
index 3d368d39c..46ff3a5cd 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/LogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/collector/LogCollector.java
@@ -18,21 +18,31 @@
package org.apache.shenyu.plugin.logging.common.collector;
import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
/**
* Collect logs and put into buffer queue.
*/
-public interface LogCollector extends AutoCloseable {
+public interface LogCollector<L extends ShenyuRequestLog> extends AutoCloseable {
/**
* start log collector.
*/
void start();
+ /**
+ * mask log.
+ *
+ * @param log log
+ * @param keyWordMatch keyWordMatch
+ * @param dataMaskALg data mask algorithm
+ */
+ void mask(L log, KeyWordMatch keyWordMatch, String dataMaskALg);
+
/**
* collect log.
*
* @param log access log
*/
- void collect(ShenyuRequestLog log);
+ void collect(L log);
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/LoggingConsolePlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/LoggingConsolePlugin.java
index 10955569b..3844c2aff 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/LoggingConsolePlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/LoggingConsolePlugin.java
@@ -29,9 +29,9 @@ import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
import org.apache.shenyu.plugin.logging.common.entity.CommonLoggingRuleHandle;
import org.apache.shenyu.plugin.logging.console.handler.LoggingConsolePluginDataHandler;
-import org.apache.shenyu.plugin.logging.mask.matcher.KeyWordMatch;
-import org.apache.shenyu.plugin.logging.mask.utils.DataMaskUtils;
-import org.apache.shenyu.plugin.logging.mask.enums.DataMaskEnums;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
+import org.apache.shenyu.plugin.logging.mask.api.utils.DataMaskUtils;
+import org.apache.shenyu.plugin.logging.mask.api.enums.DataMaskEnums;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/LoggingElasticSearchPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/LoggingElasticSearchPlugin.java
index e496441af..b79550872 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/LoggingElasticSearchPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/LoggingElasticSearchPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.logging.elasticsearch;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.elasticsearch.collector.ElasticSearchLogCollector;
+import org.springframework.web.server.ServerWebExchange;
/**
* Integrated elasticsearch collect log.
*/
-public class LoggingElasticSearchPlugin extends AbstractLoggingPlugin {
+public class LoggingElasticSearchPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return ElasticSearchLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingElasticSearchPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_ELASTIC_SEARCH;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java
index 0f17eb7b3..8679d89f3 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/client/ElasticSearchLogCollectClient.java
@@ -47,7 +47,7 @@ import java.util.Objects;
/**
* queue-based logging collector.
*/
-public class ElasticSearchLogCollectClient extends AbstractLogConsumeClient<ElasticSearchLogCollectConfig.ElasticSearchLogConfig> {
+public class ElasticSearchLogCollectClient extends AbstractLogConsumeClient<ElasticSearchLogCollectConfig.ElasticSearchLogConfig, ShenyuRequestLog> {
private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchLogCollectClient.class);
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/collector/ElasticSearchLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/collector/ElasticSearchLogCollector.java
index 84b920f8f..18c1b7d64 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/collector/ElasticSearchLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/main/java/org/apache/shenyu/plugin/logging/elasticsearch/collector/ElasticSearchLogCollector.java
@@ -19,22 +19,24 @@ package org.apache.shenyu.plugin.logging.elasticsearch.collector;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.elasticsearch.client.ElasticSearchLogCollectClient;
import org.apache.shenyu.plugin.logging.elasticsearch.handler.LoggingElasticSearchPluginDataHandler;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
/**
* elastic search log collector,depend a LogConsumeClient for consume logs.
*/
-public class ElasticSearchLogCollector extends AbstractLogCollector<ElasticSearchLogCollectClient> {
+public class ElasticSearchLogCollector extends AbstractLogCollector<ElasticSearchLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new ElasticSearchLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new ElasticSearchLogCollector();
/**
* get LogCollector instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -42,4 +44,8 @@ public class ElasticSearchLogCollector extends AbstractLogCollector<ElasticSearc
protected ElasticSearchLogCollectClient getLogConsumeClient() {
return LoggingElasticSearchPluginDataHandler.getElasticSearchLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/LoggingKafkaPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/LoggingKafkaPlugin.java
index e7dda6876..2a6d5dd5b 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/LoggingKafkaPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/LoggingKafkaPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.logging.kafka;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.kafka.collector.KafkaLogCollector;
+import org.springframework.web.server.ServerWebExchange;
/**
* Integrated kafka collect log.
*/
-public class LoggingKafkaPlugin extends AbstractLoggingPlugin {
+public class LoggingKafkaPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return KafkaLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingKafkaPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_KAFKA;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/client/KafkaLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/client/KafkaLogCollectClient.java
index da2deb516..96dcce14f 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/client/KafkaLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/client/KafkaLogCollectClient.java
@@ -49,7 +49,7 @@ import java.util.Properties;
/**
* queue-based logging collector.
*/
-public class KafkaLogCollectClient extends AbstractLogConsumeClient<KafkaLogCollectConfig.KafkaLogConfig> {
+public class KafkaLogCollectClient extends AbstractLogConsumeClient<KafkaLogCollectConfig.KafkaLogConfig, ShenyuRequestLog> {
private static Map<String, String> apiTopicMap = new HashMap<>();
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/collector/KafkaLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/collector/KafkaLogCollector.java
index ba8c75cc4..6ce3ca29a 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/collector/KafkaLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/collector/KafkaLogCollector.java
@@ -19,22 +19,24 @@ package org.apache.shenyu.plugin.logging.kafka.collector;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.kafka.client.KafkaLogCollectClient;
import org.apache.shenyu.plugin.logging.kafka.handler.LoggingKafkaPluginDataHandler;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
/**
* kafka log collector,depend a LogConsumeClient for consume logs.
*/
-public class KafkaLogCollector extends AbstractLogCollector<KafkaLogCollectClient> {
+public class KafkaLogCollector extends AbstractLogCollector<KafkaLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new KafkaLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new KafkaLogCollector();
/**
* get LogCollector instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -42,4 +44,8 @@ public class KafkaLogCollector extends AbstractLogCollector<KafkaLogCollectClien
protected KafkaLogCollectClient getLogConsumeClient() {
return LoggingKafkaPluginDataHandler.getKafkaLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/enums/DataMaskEnums.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/enums/DataMaskEnums.java
similarity index 95%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/enums/DataMaskEnums.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/enums/DataMaskEnums.java
index 389095cf0..9514554e7 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/enums/DataMaskEnums.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/enums/DataMaskEnums.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.enums;
+package org.apache.shenyu.plugin.logging.mask.api.enums;
/**
* data mask enums.
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactory.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactory.java
similarity index 91%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactory.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactory.java
index 1ad01a470..c98ac27dd 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactory.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactory.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.factory;
+package org.apache.shenyu.plugin.logging.mask.api.factory;
-import org.apache.shenyu.plugin.logging.mask.spi.ShenyuDataMask;
+import org.apache.shenyu.plugin.logging.mask.api.spi.ShenyuDataMask;
import org.apache.shenyu.spi.ExtensionLoader;
/**
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatch.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatch.java
similarity index 96%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatch.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatch.java
index 88a72e213..9be42e970 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatch.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatch.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.matcher;
+package org.apache.shenyu.plugin.logging.mask.api.matcher;
import java.util.Set;
import java.util.regex.Pattern;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/AbstractShenyuDataMask.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/AbstractShenyuDataMask.java
similarity index 95%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/AbstractShenyuDataMask.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/AbstractShenyuDataMask.java
index b1812450a..299e273b5 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/AbstractShenyuDataMask.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/AbstractShenyuDataMask.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
import org.apache.commons.lang3.StringUtils;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMask.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMask.java
similarity index 97%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMask.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMask.java
index ae9baabee..bbe833128 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMask.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMask.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
import org.apache.shenyu.spi.Join;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMask.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMask.java
similarity index 95%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMask.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMask.java
index 43eb9bd09..3c144ed4e 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMask.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMask.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
import org.apache.shenyu.common.utils.Md5Utils;
import org.apache.shenyu.spi.Join;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/ShenyuDataMask.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/ShenyuDataMask.java
similarity index 95%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/ShenyuDataMask.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/ShenyuDataMask.java
index c01270d0a..84c0cec93 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/spi/ShenyuDataMask.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/spi/ShenyuDataMask.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
import org.apache.shenyu.spi.SPI;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtils.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtils.java
similarity index 74%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtils.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtils.java
index 032762556..c75e11fe4 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtils.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtils.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.utils;
+package org.apache.shenyu.plugin.logging.mask.api.utils;
import org.apache.shenyu.common.utils.JsonUtils;
-import org.apache.shenyu.plugin.logging.mask.factory.DataMaskFactory;
-import org.apache.shenyu.plugin.logging.mask.matcher.KeyWordMatch;
+import org.apache.shenyu.plugin.logging.mask.api.factory.DataMaskFactory;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.springframework.util.StringUtils;
import java.util.List;
@@ -30,6 +30,32 @@ import java.util.Map;
*/
public final class DataMaskUtils {
+ /**
+ * mask for single key word.
+ *
+ * @param keyWord key word
+ * @param source source data
+ * @param keyWordMatch keyWordMatch
+ * @param dataMaskAlg dataMaskAlg
+ * @return masked data
+ */
+ public static String maskForSingleWord(final String keyWord, final String source,
+ final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ return DataMaskUtils.maskSingleKeyword(true, keyWord, source, keyWordMatch, dataMaskAlg);
+ }
+
+ /**
+ * mask for body.
+ *
+ * @param source source data.
+ * @param keyWordMatch keyWordMatch
+ * @param dataMaskAlg dataMaskAlg
+ * @return masked data.
+ */
+ public static String maskForBody(final String source, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ return DataMaskUtils.maskBody(true, source, keyWordMatch, dataMaskAlg);
+ }
+
/**
* mask single keyword.
*
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.spi.ShenyuDataMask b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.api.spi.ShenyuDataMask
similarity index 82%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.spi.ShenyuDataMask
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.api.spi.ShenyuDataMask
index ff7730e2c..39c78d873 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.spi.ShenyuDataMask
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/main/resources/META-INF/shenyu/org.apache.shenyu.plugin.logging.mask.api.spi.ShenyuDataMask
@@ -14,5 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-dataMaskByMD5=org.apache.shenyu.plugin.logging.mask.spi.Md5EncryptDataMask
-dataMaskByCharReplace=org.apache.shenyu.plugin.logging.mask.spi.CharacterReplaceDataMask
\ No newline at end of file
+dataMaskByMD5=org.apache.shenyu.plugin.logging.mask.api.spi.Md5EncryptDataMask
+dataMaskByCharReplace=org.apache.shenyu.plugin.logging.mask.api.spi.CharacterReplaceDataMask
\ No newline at end of file
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactoryTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactoryTest.java
similarity index 93%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactoryTest.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactoryTest.java
index f3065383c..f69e75ea8 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/factory/DataMaskFactoryTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/factory/DataMaskFactoryTest.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.factory;
+package org.apache.shenyu.plugin.logging.mask.api.factory;
import org.apache.shenyu.common.utils.Md5Utils;
-import org.apache.shenyu.plugin.logging.mask.enums.DataMaskEnums;
+import org.apache.shenyu.plugin.logging.mask.api.enums.DataMaskEnums;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatchTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatchTest.java
similarity index 96%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatchTest.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatchTest.java
index d1a4f3569..6bf83b4c8 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/matcher/KeyWordMatchTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/matcher/KeyWordMatchTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.matcher;
+package org.apache.shenyu.plugin.logging.mask.api.matcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMaskTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMaskTest.java
similarity index 89%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMaskTest.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMaskTest.java
index 8c90ab1cc..92c6bc6d9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/CharacterReplaceDataMaskTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/CharacterReplaceDataMaskTest.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
-import org.apache.shenyu.plugin.logging.mask.enums.DataMaskEnums;
-import org.apache.shenyu.plugin.logging.mask.factory.DataMaskFactory;
+import org.apache.shenyu.plugin.logging.mask.api.enums.DataMaskEnums;
+import org.apache.shenyu.plugin.logging.mask.api.factory.DataMaskFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMaskTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMaskTest.java
similarity index 95%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMaskTest.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMaskTest.java
index 558854bef..94d5b4fdc 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/spi/Md5EncryptDataMaskTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/spi/Md5EncryptDataMaskTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.spi;
+package org.apache.shenyu.plugin.logging.mask.api.spi;
import org.apache.shenyu.common.utils.Md5Utils;
import org.junit.jupiter.api.Assertions;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtilsTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtilsTest.java
similarity index 94%
rename from shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtilsTest.java
rename to shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtilsTest.java
index edf9ecf9b..867a3b455 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/utils/DataMaskUtilsTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-mask-api/src/test/java/org/apache/shenyu/plugin/logging/mask/api/utils/DataMaskUtilsTest.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shenyu.plugin.logging.mask.utils;
+package org.apache.shenyu.plugin.logging.mask.api.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.shenyu.common.utils.JsonUtils;
import org.apache.shenyu.common.utils.Md5Utils;
-import org.apache.shenyu.plugin.logging.mask.enums.DataMaskEnums;
-import org.apache.shenyu.plugin.logging.mask.matcher.KeyWordMatch;
+import org.apache.shenyu.plugin.logging.mask.api.enums.DataMaskEnums;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/LoggingPulsarPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/LoggingPulsarPlugin.java
index 9f9f566cc..cda70ce72 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/LoggingPulsarPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/LoggingPulsarPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.logging.pulsar;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.pulsar.collector.PulsarLogCollector;
+import org.springframework.web.server.ServerWebExchange;
/**
* Integrated pulsar collect log.
*/
-public class LoggingPulsarPlugin extends AbstractLoggingPlugin {
+public class LoggingPulsarPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return PulsarLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingPulsarPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_PULSAR;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/client/PulsarLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/client/PulsarLogCollectClient.java
index 6cf96ee0d..f614a3c0e 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/client/PulsarLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/client/PulsarLogCollectClient.java
@@ -39,7 +39,7 @@ import java.util.Objects;
/**
* queue-based logging collector.
*/
-public class PulsarLogCollectClient extends AbstractLogConsumeClient<PulsarLogCollectConfig.PulsarLogConfig> {
+public class PulsarLogCollectClient extends AbstractLogConsumeClient<PulsarLogCollectConfig.PulsarLogConfig, ShenyuRequestLog> {
private static final Logger LOG = LoggerFactory.getLogger(PulsarLogCollectClient.class);
private PulsarClient client;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/collector/PulsarLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/collector/PulsarLogCollector.java
index 338637ec8..39a179bb9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/collector/PulsarLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-pulsar/src/main/java/org/apache/shenyu/plugin/logging/pulsar/collector/PulsarLogCollector.java
@@ -19,19 +19,21 @@ package org.apache.shenyu.plugin.logging.pulsar.collector;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.apache.shenyu.plugin.logging.pulsar.client.PulsarLogCollectClient;
import org.apache.shenyu.plugin.logging.pulsar.handler.LoggingPulsarPluginDataHandler;
-public class PulsarLogCollector extends AbstractLogCollector<PulsarLogCollectClient> {
+public class PulsarLogCollector extends AbstractLogCollector<PulsarLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new PulsarLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new PulsarLogCollector();
/**
* get LogCollector Instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -39,4 +41,8 @@ public class PulsarLogCollector extends AbstractLogCollector<PulsarLogCollectCli
protected PulsarLogCollectClient getLogConsumeClient() {
return LoggingPulsarPluginDataHandler.getPulsarLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/LoggingRocketMQPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/LoggingRocketMQPlugin.java
index 4f0caaccb..ae18a7eb0 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/LoggingRocketMQPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/LoggingRocketMQPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.logging.rocketmq;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.logging.rocketmq.collector.RocketMQLogCollector;
+import org.springframework.web.server.ServerWebExchange;
/**
* Integrated rocketmq collect log.
*/
-public class LoggingRocketMQPlugin extends AbstractLoggingPlugin {
+public class LoggingRocketMQPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return RocketMQLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingRocketMQPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_ROCKETMQ;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClient.java
index 0dbc66627..2555a26da 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClient.java
@@ -45,7 +45,7 @@ import java.util.Optional;
/**
* queue-based logging collector.
*/
-public class RocketMQLogCollectClient extends AbstractLogConsumeClient<RocketMQLogCollectConfig.RocketMQLogConfig> {
+public class RocketMQLogCollectClient extends AbstractLogConsumeClient<RocketMQLogCollectConfig.RocketMQLogConfig, ShenyuRequestLog> {
private static final Logger LOG = LoggerFactory.getLogger(RocketMQLogCollectClient.class);
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/collector/RocketMQLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/collector/RocketMQLogCollector.java
index 821e89054..15dd00adf 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/collector/RocketMQLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/main/java/org/apache/shenyu/plugin/logging/rocketmq/collector/RocketMQLogCollector.java
@@ -19,22 +19,24 @@ package org.apache.shenyu.plugin.logging.rocketmq.collector;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.apache.shenyu.plugin.logging.rocketmq.client.RocketMQLogCollectClient;
import org.apache.shenyu.plugin.logging.rocketmq.handler.LoggingRocketMQPluginDataHandler;
/**
* default log collector,depend a LogConsumeClient for consume logs.
*/
-public class RocketMQLogCollector extends AbstractLogCollector<RocketMQLogCollectClient> {
+public class RocketMQLogCollector extends AbstractLogCollector<RocketMQLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new RocketMQLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new RocketMQLogCollector();
/**
* get LogCollector instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -42,4 +44,8 @@ public class RocketMQLogCollector extends AbstractLogCollector<RocketMQLogCollec
protected RocketMQLogCollectClient getLogConsumeClient() {
return LoggingRocketMQPluginDataHandler.getRocketMqLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/LoggingTencentClsPlugin.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/LoggingTencentClsPlugin.java
index 649159c6b..e36c14c2a 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/LoggingTencentClsPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/LoggingTencentClsPlugin.java
@@ -17,18 +17,22 @@
package org.apache.shenyu.plugin.tencent.cls;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
import org.apache.shenyu.plugin.tencent.cls.collector.TencentClsSlsLogCollector;
+import org.springframework.web.server.ServerWebExchange;
/**
* LoggingTencentClsPlugin send log to Tencent cls service.
*/
-public class LoggingTencentClsPlugin extends AbstractLoggingPlugin {
+public class LoggingTencentClsPlugin extends AbstractLoggingPlugin<ShenyuRequestLog> {
@Override
- protected LogCollector logCollector() {
+ protected LogCollector<ShenyuRequestLog> logCollector() {
return TencentClsSlsLogCollector.getInstance();
}
@@ -41,4 +45,18 @@ public class LoggingTencentClsPlugin extends AbstractLoggingPlugin {
public PluginEnum pluginEnum() {
return PluginEnum.LOGGING_TENCENT_CLS;
}
+
+ /**
+ * log collect extension.
+ * base on ShenyuRequestLog to extend log
+ *
+ * @param exchange exchange
+ * @param selector selector
+ * @param rule rule
+ * @return base ShenyuRequestLog
+ */
+ @Override
+ protected ShenyuRequestLog doLogExecute(final ServerWebExchange exchange, final SelectorData selector, final RuleData rule) {
+ return new ShenyuRequestLog();
+ }
}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/client/TencentClsLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/client/TencentClsLogCollectClient.java
index 3a39bdf4e..31bfaf7ae 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/client/TencentClsLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/client/TencentClsLogCollectClient.java
@@ -52,7 +52,7 @@ import java.util.concurrent.TimeUnit;
/**
* Tencent cls log Collect client.
*/
-public class TencentClsLogCollectClient extends AbstractLogConsumeClient<TencentLogCollectConfig.TencentClsLogConfig> {
+public class TencentClsLogCollectClient extends AbstractLogConsumeClient<TencentLogCollectConfig.TencentClsLogConfig, ShenyuRequestLog> {
private AsyncProducerClient client;
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/collector/TencentClsSlsLogCollector.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/collector/TencentClsSlsLogCollector.java
index 110739a43..86bbb6bcd 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/collector/TencentClsSlsLogCollector.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/src/main/java/org/apache/shenyu/plugin/tencent/cls/collector/TencentClsSlsLogCollector.java
@@ -19,22 +19,24 @@ package org.apache.shenyu.plugin.tencent.cls.collector;
import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.apache.shenyu.plugin.logging.mask.api.matcher.KeyWordMatch;
import org.apache.shenyu.plugin.tencent.cls.client.TencentClsLogCollectClient;
import org.apache.shenyu.plugin.tencent.cls.handler.LoggingTencentClsPluginDataHandler;
/**
* Tencent cls log collector,depend a LogConsumeClient for consume logs.
*/
-public class TencentClsSlsLogCollector extends AbstractLogCollector<TencentClsLogCollectClient> {
+public class TencentClsSlsLogCollector extends AbstractLogCollector<TencentClsLogCollectClient, ShenyuRequestLog> {
- private static final LogCollector INSTANCE = new TencentClsSlsLogCollector();
+ private static final LogCollector<ShenyuRequestLog> INSTANCE = new TencentClsSlsLogCollector();
/**
* get LogCollector instance.
*
* @return LogCollector instance
*/
- public static LogCollector getInstance() {
+ public static LogCollector<ShenyuRequestLog> getInstance() {
return INSTANCE;
}
@@ -42,4 +44,8 @@ public class TencentClsSlsLogCollector extends AbstractLogCollector<TencentClsLo
protected TencentClsLogCollectClient getLogConsumeClient() {
return LoggingTencentClsPluginDataHandler.getTencentClsLogCollectClient();
}
+
+ @Override
+ protected void maskLog(final ShenyuRequestLog log, final KeyWordMatch keyWordMatch, final String dataMaskAlg) {
+ }
}