From cc2d1a69a9398c4f8bfa6dfe5ffae63ecfce487c Mon Sep 17 00:00:00 2001 From: nickChenyx Date: Thu, 17 Sep 2020 20:42:01 +0800 Subject: [PATCH] Optimize logging statements using placeholder (#1736) * Optimize logging statements using placeholder to avoid unnecessary concatenation (issue #1735) --- .../common/api/GatewayApiDefinitionManager.java | 8 ++++---- .../command/UpdateGatewayRuleCommandHandler.java | 4 ++-- .../gateway/common/rule/GatewayRuleManager.java | 6 +++--- .../cluster/client/DefaultClusterTokenClient.java | 4 ++-- .../cluster/client/NettyTransportClient.java | 5 ++--- .../client/codec/ClientEntityCodecProvider.java | 6 ++++-- .../client/config/ClusterClientConfigManager.java | 6 +++--- .../cluster/client/handler/TokenClientHandler.java | 6 +++--- .../handler/ModifyClusterClientConfigHandler.java | 2 +- .../cluster/registry/ConfigSupplierRegistry.java | 4 ++-- .../concurrent/expire/RegularExpireStrategy.java | 2 +- .../cluster/server/NettyTransportServer.java | 2 +- .../server/codec/ServerEntityCodecProvider.java | 10 ++++------ .../ModifyClusterServerFlowConfigHandler.java | 2 +- .../handler/ModifyServerNamespaceSetHandler.java | 2 +- .../server/config/ClusterServerConfigManager.java | 10 +++++----- .../server/connection/ScanIdleConnectionTask.java | 6 ++---- .../server/envoy/rls/rule/EnvoyRlsRuleManager.java | 2 +- .../cluster/client/TokenClientProvider.java | 4 ++-- .../server/EmbeddedClusterTokenServerProvider.java | 3 ++- .../alibaba/csp/sentinel/config/SentinelConfig.java | 2 +- .../csp/sentinel/config/SentinelConfigLoader.java | 2 +- .../com/alibaba/csp/sentinel/init/InitExecutor.java | 6 +++--- .../metric/extension/MetricExtensionProvider.java | 2 +- .../alibaba/csp/sentinel/node/IntervalProperty.java | 2 +- .../csp/sentinel/node/OccupyTimeoutProperty.java | 6 +++--- .../csp/sentinel/node/SampleCountProperty.java | 2 +- .../csp/sentinel/node/metric/MetricWriter.java | 13 ++++++------- .../sentinel/property/DynamicSentinelProperty.java | 2 +- .../csp/sentinel/slotchain/SlotChainProvider.java | 4 ++-- .../slots/block/authority/AuthorityRuleManager.java | 8 ++++---- .../slots/block/degrade/DegradeRuleManager.java | 8 ++++---- .../sentinel/slots/block/flow/FlowRuleManager.java | 4 ++-- .../datasource/apollo/ApolloDataSource.java | 4 ++-- .../sentinel/datasource/FileWritableDataSource.java | 2 +- .../sentinel/datasource/nacos/NacosDataSource.java | 4 ++-- .../sentinel/datasource/redis/RedisDataSource.java | 2 +- .../spring/cloud/config/SentinelRuleLocator.java | 7 +++---- .../datasource/zookeeper/ZookeeperDataSource.java | 4 ++-- .../handler/ModifyParamFlowRulesCommandHandler.java | 2 +- .../block/flow/param/ParamFlowRuleManager.java | 4 ++-- .../block/flow/param/ParameterMetricStorage.java | 4 ++-- .../csp/sentinel/command/CommandCenterProvider.java | 2 +- .../cluster/ModifyClusterModeCommandHandler.java | 2 +- .../sentinel/heartbeat/HeartbeatSenderProvider.java | 2 +- .../transport/heartbeat/HttpHeartbeatSender.java | 3 +-- .../heartbeat/SimpleHttpHeartbeatSender.java | 2 +- 47 files changed, 97 insertions(+), 102 deletions(-) diff --git a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/GatewayApiDefinitionManager.java b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/GatewayApiDefinitionManager.java index 7e37d60c..8f24803c 100644 --- a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/GatewayApiDefinitionManager.java +++ b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/api/GatewayApiDefinitionManager.java @@ -62,8 +62,8 @@ public final class GatewayApiDefinitionManager { List listeners = SpiLoader.loadInstanceList(ApiDefinitionChangeObserver.class); for (ApiDefinitionChangeObserver e : listeners) { API_CHANGE_OBSERVERS.put(e.getClass().getCanonicalName(), e); - RecordLog.info("[GatewayApiDefinitionManager] ApiDefinitionChangeObserver added: " - + e.getClass().getCanonicalName()); + RecordLog.info("[GatewayApiDefinitionManager] ApiDefinitionChangeObserver added: {}" + , e.getClass().getCanonicalName()); } } @@ -103,13 +103,13 @@ public final class GatewayApiDefinitionManager { @Override public void configUpdate(Set set) { applyApiUpdateInternal(set); - RecordLog.info("[GatewayApiDefinitionManager] Api definition updated: " + API_MAP); + RecordLog.info("[GatewayApiDefinitionManager] Api definition updated: {}", API_MAP); } @Override public void configLoad(Set set) { applyApiUpdateInternal(set); - RecordLog.info("[GatewayApiDefinitionManager] Api definition loaded: " + API_MAP); + RecordLog.info("[GatewayApiDefinitionManager] Api definition loaded: {}", API_MAP); } private static synchronized void applyApiUpdateInternal(Set set) { diff --git a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/command/UpdateGatewayRuleCommandHandler.java b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/command/UpdateGatewayRuleCommandHandler.java index b79b78f9..a5e6d0f8 100644 --- a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/command/UpdateGatewayRuleCommandHandler.java +++ b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/command/UpdateGatewayRuleCommandHandler.java @@ -51,7 +51,7 @@ public class UpdateGatewayRuleCommandHandler implements CommandHandler { return CommandResponse.ofFailure(e, "decode gateway rule data error"); } - RecordLog.info(String.format("[API Server] Receiving rule change (type: gateway rule): %s", data)); + RecordLog.info("[API Server] Receiving rule change (type: gateway rule): {}", data); String result = SUCCESS_MSG; Set flowRules = JSON.parseObject(data, new TypeReference>() { @@ -93,4 +93,4 @@ public class UpdateGatewayRuleCommandHandler implements CommandHandler { private static final String SUCCESS_MSG = "success"; private static final String WRITE_DS_FAILURE_MSG = "partial success (write data source failed)"; -} \ No newline at end of file +} diff --git a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/rule/GatewayRuleManager.java b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/rule/GatewayRuleManager.java index 9476b5f3..dce2778a 100644 --- a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/rule/GatewayRuleManager.java +++ b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/rule/GatewayRuleManager.java @@ -149,13 +149,13 @@ public final class GatewayRuleManager { @Override public void configUpdate(Set conf) { applyGatewayRuleInternal(conf); - RecordLog.info("[GatewayRuleManager] Gateway flow rules received: " + GATEWAY_RULE_MAP); + RecordLog.info("[GatewayRuleManager] Gateway flow rules received: {}", GATEWAY_RULE_MAP); } @Override public void configLoad(Set conf) { applyGatewayRuleInternal(conf); - RecordLog.info("[GatewayRuleManager] Gateway flow rules loaded: " + GATEWAY_RULE_MAP); + RecordLog.info("[GatewayRuleManager] Gateway flow rules loaded: {}", GATEWAY_RULE_MAP); } private int getIdxInternal(Map idxMap, String resourceName) { @@ -271,7 +271,7 @@ public final class GatewayRuleManager { CONVERTED_PARAM_RULE_MAP.clear(); CONVERTED_PARAM_RULE_MAP.putAll(newRuleMap); - RecordLog.info("[GatewayRuleManager] Converted internal param rules: " + CONVERTED_PARAM_RULE_MAP); + RecordLog.info("[GatewayRuleManager] Converted internal param rules: {}", CONVERTED_PARAM_RULE_MAP); } } } diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/DefaultClusterTokenClient.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/DefaultClusterTokenClient.java index d2bf88a4..1a0acf6c 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/DefaultClusterTokenClient.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/DefaultClusterTokenClient.java @@ -79,7 +79,7 @@ public class DefaultClusterTokenClient implements ClusterTokenClient { try { this.transportClient = new NettyTransportClient(host, port); this.serverDescriptor = new TokenServerDescriptor(host, port); - RecordLog.info("[DefaultClusterTokenClient] New client created: " + serverDescriptor); + RecordLog.info("[DefaultClusterTokenClient] New client created: {}", serverDescriptor); } catch (Exception ex) { RecordLog.warn("[DefaultClusterTokenClient] Failed to initialize new token client", ex); } @@ -97,7 +97,7 @@ public class DefaultClusterTokenClient implements ClusterTokenClient { this.transportClient = new NettyTransportClient(config.getServerHost(), config.getServerPort()); this.serverDescriptor = new TokenServerDescriptor(config.getServerHost(), config.getServerPort()); startClientIfScheduled(); - RecordLog.info("[DefaultClusterTokenClient] New client created: " + serverDescriptor); + RecordLog.info("[DefaultClusterTokenClient] New client created: {}", serverDescriptor); } catch (Exception ex) { RecordLog.warn("[DefaultClusterTokenClient] Failed to change remote token server", ex); } diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java index 23c9f2f4..51823d3b 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/NettyTransportClient.java @@ -126,8 +126,7 @@ public class NettyTransportClient implements ClusterTransportClient { } else { failConnectedTime.set(0); channel = future.channel(); - RecordLog.info( - "[NettyTransportClient] Successfully connect to server <" + host + ":" + port + ">"); + RecordLog.info("[NettyTransportClient] Successfully connect to server <{}:{}>", host, port); } } }); @@ -144,7 +143,7 @@ public class NettyTransportClient implements ClusterTransportClient { @Override public void run() { if (shouldRetry.get()) { - RecordLog.info("[NettyTransportClient] Reconnecting to server <" + host + ":" + port + ">"); + RecordLog.info("[NettyTransportClient] Reconnecting to server <{}:{}>", host, port); try { startInternal(); } catch (Exception e) { diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/codec/ClientEntityCodecProvider.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/codec/ClientEntityCodecProvider.java index 6cb0ebda..e27ce682 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/codec/ClientEntityCodecProvider.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/codec/ClientEntityCodecProvider.java @@ -39,14 +39,16 @@ public final class ClientEntityCodecProvider { RecordLog.warn("[ClientEntityCodecProvider] No existing request entity writer, resolve failed"); } else { requestEntityWriter = writer; - RecordLog.info("[ClientEntityCodecProvider] Request entity writer resolved: " + requestEntityWriter.getClass().getCanonicalName()); + RecordLog.info("[ClientEntityCodecProvider] Request entity writer resolved: {}", + requestEntityWriter.getClass().getCanonicalName()); } ResponseEntityDecoder decoder = SpiLoader.loadFirstInstance(ResponseEntityDecoder.class); if (decoder == null) { RecordLog.warn("[ClientEntityCodecProvider] No existing response entity decoder, resolve failed"); } else { responseEntityDecoder = decoder; - RecordLog.info("[ClientEntityCodecProvider] Response entity decoder resolved: " + responseEntityDecoder.getClass().getCanonicalName()); + RecordLog.info("[ClientEntityCodecProvider] Response entity decoder resolved: {}", + responseEntityDecoder.getClass().getCanonicalName()); } } diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/config/ClusterClientConfigManager.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/config/ClusterClientConfigManager.java index 27da9801..59a958e3 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/config/ClusterClientConfigManager.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/config/ClusterClientConfigManager.java @@ -131,7 +131,7 @@ public final class ClusterClientConfigManager { return; } - RecordLog.info("[ClusterClientConfigManager] Assign to new target token server: " + config); + RecordLog.info("[ClusterClientConfigManager] Assign to new target token server: {}", config); updateServerAssignment(config); } @@ -156,11 +156,11 @@ public final class ClusterClientConfigManager { private synchronized void applyConfig(ClusterClientConfig config) { if (!isValidClientConfig(config)) { RecordLog.warn( - "[ClusterClientConfigManager] Invalid cluster client config, ignoring: " + config); + "[ClusterClientConfigManager] Invalid cluster client config, ignoring: {}", config); return; } - RecordLog.info("[ClusterClientConfigManager] Updating to new client config: " + config); + RecordLog.info("[ClusterClientConfigManager] Updating to new client config: {}", config); updateClientConfigChange(config); } diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/handler/TokenClientHandler.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/handler/TokenClientHandler.java index 8a16c630..41ee220d 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/handler/TokenClientHandler.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/cluster/client/handler/TokenClientHandler.java @@ -48,7 +48,7 @@ public class TokenClientHandler extends ChannelInboundHandlerAdapter { public void channelActive(ChannelHandlerContext ctx) throws Exception { currentState.set(ClientConstants.CLIENT_STATUS_STARTED); fireClientPing(ctx); - RecordLog.info("[TokenClientHandler] Client handler active, remote address: " + getRemoteAddress(ctx)); + RecordLog.info("[TokenClientHandler] Client handler active, remote address: {}", getRemoteAddress(ctx)); } @Override @@ -90,12 +90,12 @@ public class TokenClientHandler extends ChannelInboundHandlerAdapter { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { - RecordLog.info("[TokenClientHandler] Client handler inactive, remote address: " + getRemoteAddress(ctx)); + RecordLog.info("[TokenClientHandler] Client handler inactive, remote address: {}", getRemoteAddress(ctx)); } @Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { - RecordLog.info("[TokenClientHandler] Client channel unregistered, remote address: " + getRemoteAddress(ctx)); + RecordLog.info("[TokenClientHandler] Client channel unregistered, remote address: {}", getRemoteAddress(ctx)); currentState.set(ClientConstants.CLIENT_STATUS_OFF); disconnectCallback.run(); diff --git a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyClusterClientConfigHandler.java b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyClusterClientConfigHandler.java index 189e7942..ecef1de9 100644 --- a/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyClusterClientConfigHandler.java +++ b/sentinel-cluster/sentinel-cluster-client-default/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyClusterClientConfigHandler.java @@ -44,7 +44,7 @@ public class ModifyClusterClientConfigHandler implements CommandHandler } try { data = URLDecoder.decode(data, "utf-8"); - RecordLog.info("[ModifyClusterClientConfigHandler] Receiving cluster client config: " + data); + RecordLog.info("[ModifyClusterClientConfigHandler] Receiving cluster client config: {}", data); ClusterClientStateEntity entity = JSON.parseObject(data, ClusterClientStateEntity.class); ClusterClientConfigManager.applyNewConfig(entity.toClientConfig()); diff --git a/sentinel-cluster/sentinel-cluster-common-default/src/main/java/com/alibaba/csp/sentinel/cluster/registry/ConfigSupplierRegistry.java b/sentinel-cluster/sentinel-cluster-common-default/src/main/java/com/alibaba/csp/sentinel/cluster/registry/ConfigSupplierRegistry.java index 63107d52..2284da93 100644 --- a/sentinel-cluster/sentinel-cluster-common-default/src/main/java/com/alibaba/csp/sentinel/cluster/registry/ConfigSupplierRegistry.java +++ b/sentinel-cluster/sentinel-cluster-common-default/src/main/java/com/alibaba/csp/sentinel/cluster/registry/ConfigSupplierRegistry.java @@ -52,8 +52,8 @@ public final class ConfigSupplierRegistry { public static void setNamespaceSupplier(Supplier namespaceSupplier) { AssertUtil.notNull(namespaceSupplier, "namespaceSupplier cannot be null"); ConfigSupplierRegistry.namespaceSupplier = namespaceSupplier; - RecordLog.info("[ConfigSupplierRegistry] New namespace supplier provided, current supplied: " - + namespaceSupplier.get()); + RecordLog.info("[ConfigSupplierRegistry] New namespace supplier provided, current supplied: {}", + namespaceSupplier.get()); } private ConfigSupplierRegistry() {} diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/concurrent/expire/RegularExpireStrategy.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/concurrent/expire/RegularExpireStrategy.java index 5222e7b3..0aa633a0 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/concurrent/expire/RegularExpireStrategy.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/statistic/concurrent/expire/RegularExpireStrategy.java @@ -97,7 +97,7 @@ public class RegularExpireStrategy implements ExpireStrategy { for (int i = 0; i < executeCount && i < keyList.size(); i++) { // time out execution exit if (System.currentTimeMillis() - start > executeDuration) { - RecordLog.info("[RegularExpireStrategy] End the process of expired token detection because of execute time is more than executeDuration:", executeDuration); + RecordLog.info("[RegularExpireStrategy] End the process of expired token detection because of execute time is more than executeDuration: {}", executeDuration); break; } Long key = keyList.get(i); diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/NettyTransportServer.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/NettyTransportServer.java index a3f06979..25468551 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/NettyTransportServer.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/NettyTransportServer.java @@ -118,7 +118,7 @@ public class NettyTransportServer implements ClusterTokenServer { RecordLog.info("[NettyTransportServer] Failed to start token server when retrying", e); } } else { - RecordLog.info("[NettyTransportServer] Token server started success at port " + port); + RecordLog.info("[NettyTransportServer] Token server started success at port {}", port); currentState.compareAndSet(SERVER_STATUS_STARTING, SERVER_STATUS_STARTED); } } diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/codec/ServerEntityCodecProvider.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/codec/ServerEntityCodecProvider.java index ada283ab..741570e2 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/codec/ServerEntityCodecProvider.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/codec/ServerEntityCodecProvider.java @@ -39,18 +39,16 @@ public final class ServerEntityCodecProvider { RecordLog.warn("[ServerEntityCodecProvider] No existing response entity writer, resolve failed"); } else { responseEntityWriter = writer; - RecordLog.info( - "[ServerEntityCodecProvider] Response entity writer resolved: " + responseEntityWriter.getClass() - .getCanonicalName()); + RecordLog.info("[ServerEntityCodecProvider] Response entity writer resolved: {}", + responseEntityWriter.getClass().getCanonicalName()); } RequestEntityDecoder decoder = SpiLoader.loadFirstInstance(RequestEntityDecoder.class); if (decoder == null) { RecordLog.warn("[ServerEntityCodecProvider] No existing request entity decoder, resolve failed"); } else { requestEntityDecoder = decoder; - RecordLog.info( - "[ServerEntityCodecProvider] Request entity decoder resolved: " + requestEntityDecoder.getClass() - .getCanonicalName()); + RecordLog.info("[ServerEntityCodecProvider] Request entity decoder resolved: {}", + requestEntityDecoder.getClass().getCanonicalName()); } } diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/command/handler/ModifyClusterServerFlowConfigHandler.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/command/handler/ModifyClusterServerFlowConfigHandler.java index 5fac5a8c..c5802421 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/command/handler/ModifyClusterServerFlowConfigHandler.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/command/handler/ModifyClusterServerFlowConfigHandler.java @@ -46,7 +46,7 @@ public class ModifyClusterServerFlowConfigHandler implements CommandHandler { } try { data = URLDecoder.decode(data, "utf-8"); - RecordLog.info("[ModifyServerNamespaceSetHandler] Receiving cluster server namespace set: " + data); + RecordLog.info("[ModifyServerNamespaceSetHandler] Receiving cluster server namespace set: {}", data); Set set = JSON.parseObject(data, new TypeReference>() {}); ClusterServerConfigManager.loadServerNamespaceSet(set); return CommandResponse.ofSuccess("success"); diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/config/ClusterServerConfigManager.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/config/ClusterServerConfigManager.java index b3d3fcd6..5da3b782 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/config/ClusterServerConfigManager.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/config/ClusterServerConfigManager.java @@ -219,7 +219,7 @@ public final class ClusterServerConfigManager { if (newSet == null) { return; } - RecordLog.info("[ClusterServerConfigManager] Server namespace set will be update to: " + newSet); + RecordLog.info("[ClusterServerConfigManager] Server namespace set will be update to: {}", newSet); if (newSet.isEmpty()) { ClusterServerConfigManager.namespaceSet = Collections.singleton(ServerConstants.DEFAULT_NAMESPACE); return; @@ -276,10 +276,10 @@ public final class ClusterServerConfigManager { private synchronized void applyConfig(ServerTransportConfig config) { if (!isValidTransportConfig(config)) { RecordLog.warn( - "[ClusterServerConfigManager] Invalid cluster server transport config, ignoring: " + config); + "[ClusterServerConfigManager] Invalid cluster server transport config, ignoring: {}", config); return; } - RecordLog.info("[ClusterServerConfigManager] Updating new server transport config: " + config); + RecordLog.info("[ClusterServerConfigManager] Updating new server transport config: {}", config); if (config.getIdleSeconds() != idleSeconds) { idleSeconds = config.getIdleSeconds(); } @@ -315,10 +315,10 @@ public final class ClusterServerConfigManager { private synchronized void applyGlobalFlowConfig(ServerFlowConfig config) { if (!isValidFlowConfig(config)) { RecordLog.warn( - "[ClusterServerConfigManager] Invalid cluster server global flow config, ignoring: " + config); + "[ClusterServerConfigManager] Invalid cluster server global flow config, ignoring: {}", config); return; } - RecordLog.info("[ClusterServerConfigManager] Updating new server global flow config: " + config); + RecordLog.info("[ClusterServerConfigManager] Updating new server global flow config: {}", config); if (config.getExceedCount() != exceedCount) { exceedCount = config.getExceedCount(); } diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ScanIdleConnectionTask.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ScanIdleConnectionTask.java index a559aeeb..b3ed1180 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ScanIdleConnectionTask.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ScanIdleConnectionTask.java @@ -31,10 +31,8 @@ public class ScanIdleConnectionTask implements Runnable { List connections = connectionPool.listAllConnection(); for (Connection conn : connections) { if ((now - conn.getLastReadTime()) > idleTimeMillis) { - RecordLog.info( - String.format("[ScanIdleConnectionTask] The connection <%s:%d> has been idle for <%d>s. " - + "It will be closed now.", conn.getRemoteIP(), conn.getRemotePort(), idleSeconds) - ); + RecordLog.info("[ScanIdleConnectionTask] The connection <{}:{}> has been idle for <{}>s. It will be closed now.", + conn.getRemoteIP(), conn.getRemotePort(), idleSeconds); conn.close(); } } diff --git a/sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoyRlsRuleManager.java b/sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoyRlsRuleManager.java index 1acca600..029fc148 100644 --- a/sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoyRlsRuleManager.java +++ b/sentinel-cluster/sentinel-cluster-server-envoy-rls/src/main/java/com/alibaba/csp/sentinel/cluster/server/envoy/rls/rule/EnvoyRlsRuleManager.java @@ -91,7 +91,7 @@ public final class EnvoyRlsRuleManager { RULE_MAP.clear(); RULE_MAP.putAll(ruleMap); - RecordLog.info("[EnvoyRlsRuleManager] Envoy RLS rules loaded: " + flowRules); + RecordLog.info("[EnvoyRlsRuleManager] Envoy RLS rules loaded: {}", flowRules); // Use the "default" namespace. ClusterFlowRuleManager.loadRules(ServerConstants.DEFAULT_NAMESPACE, flowRules); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/client/TokenClientProvider.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/client/TokenClientProvider.java index def2f016..85c9da2f 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/client/TokenClientProvider.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/client/TokenClientProvider.java @@ -44,8 +44,8 @@ public final class TokenClientProvider { "[TokenClientProvider] No existing cluster token client, cluster client mode will not be activated"); } else { client = resolvedClient; - RecordLog.info( - "[TokenClientProvider] Cluster token client resolved: " + client.getClass().getCanonicalName()); + RecordLog.info("[TokenClientProvider] Cluster token client resolved: {}", + client.getClass().getCanonicalName()); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/server/EmbeddedClusterTokenServerProvider.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/server/EmbeddedClusterTokenServerProvider.java index 6b76af93..2f55e811 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/server/EmbeddedClusterTokenServerProvider.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/server/EmbeddedClusterTokenServerProvider.java @@ -36,7 +36,8 @@ public final class EmbeddedClusterTokenServerProvider { RecordLog.warn("[EmbeddedClusterTokenServerProvider] No existing cluster token server, cluster server mode will not be activated"); } else { server = s; - RecordLog.info("[EmbeddedClusterTokenServerProvider] Cluster token server resolved: " + server.getClass().getCanonicalName()); + RecordLog.info("[EmbeddedClusterTokenServerProvider] Cluster token server resolved: {}", + server.getClass().getCanonicalName()); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfig.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfig.java index 996432d7..f86bdc4e 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfig.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfig.java @@ -68,7 +68,7 @@ public final class SentinelConfig { loadProps(); resolveAppName(); resolveAppType(); - RecordLog.info("[SentinelConfig] Application type resolved: " + appType); + RecordLog.info("[SentinelConfig] Application type resolved: {}", appType); } catch (Throwable ex) { RecordLog.warn("[SentinelConfig] Failed to initialize", ex); ex.printStackTrace(); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfigLoader.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfigLoader.java index a6ed1442..e267ed77 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfigLoader.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfigLoader.java @@ -62,7 +62,7 @@ public final class SentinelConfigLoader { Properties p = ConfigUtil.loadProperties(fileName); if (p != null && !p.isEmpty()) { - RecordLog.info("[SentinelConfigLoader] Loading Sentinel config from " + fileName); + RecordLog.info("[SentinelConfigLoader] Loading Sentinel config from {}", fileName); properties.putAll(p); } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/init/InitExecutor.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/init/InitExecutor.java index e68fd599..8e63889d 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/init/InitExecutor.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/init/InitExecutor.java @@ -46,13 +46,13 @@ public final class InitExecutor { ServiceLoader loader = ServiceLoaderUtil.getServiceLoader(InitFunc.class); List initList = new ArrayList(); for (InitFunc initFunc : loader) { - RecordLog.info("[InitExecutor] Found init func: " + initFunc.getClass().getCanonicalName()); + RecordLog.info("[InitExecutor] Found init func: {}", initFunc.getClass().getCanonicalName()); insertSorted(initList, initFunc); } for (OrderWrapper w : initList) { w.func.init(); - RecordLog.info(String.format("[InitExecutor] Executing %s with order %d", - w.func.getClass().getCanonicalName(), w.order)); + RecordLog.info("[InitExecutor] Executing {} with order {}", + w.func.getClass().getCanonicalName(), w.order); } } catch (Exception ex) { RecordLog.warn("[InitExecutor] WARN: Initialization failed", ex); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/metric/extension/MetricExtensionProvider.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/metric/extension/MetricExtensionProvider.java index 79784ae7..75da7fe7 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/metric/extension/MetricExtensionProvider.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/metric/extension/MetricExtensionProvider.java @@ -41,7 +41,7 @@ public class MetricExtensionProvider { RecordLog.info("[MetricExtensionProvider] No existing MetricExtension found"); } else { metricExtensions.addAll(extensions); - RecordLog.info("[MetricExtensionProvider] MetricExtension resolved, size=" + extensions.size()); + RecordLog.info("[MetricExtensionProvider] MetricExtension resolved, size={}", extensions.size()); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/IntervalProperty.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/IntervalProperty.java index 4f0dfa7b..8bdd4d7e 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/IntervalProperty.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/IntervalProperty.java @@ -62,7 +62,7 @@ public class IntervalProperty { INTERVAL = newInterval; ClusterBuilderSlot.resetClusterNodes(); } - RecordLog.info("[IntervalProperty] INTERVAL updated to: " + INTERVAL); + RecordLog.info("[IntervalProperty] INTERVAL updated to: {}", INTERVAL); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/OccupyTimeoutProperty.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/OccupyTimeoutProperty.java index a2d7ecf3..386b09c4 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/OccupyTimeoutProperty.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/OccupyTimeoutProperty.java @@ -67,13 +67,13 @@ public class OccupyTimeoutProperty { return; } if (newInterval > IntervalProperty.INTERVAL) { - RecordLog.warn("[OccupyTimeoutProperty] Illegal timeout value will be ignored: " + occupyTimeout - + ", should <= " + IntervalProperty.INTERVAL); + RecordLog.warn("[OccupyTimeoutProperty] Illegal timeout value will be ignored: {}, should <= {}", + occupyTimeout, IntervalProperty.INTERVAL); return; } if (newInterval != occupyTimeout) { occupyTimeout = newInterval; } - RecordLog.info("[OccupyTimeoutProperty] occupyTimeout updated to: " + occupyTimeout); + RecordLog.info("[OccupyTimeoutProperty] occupyTimeout updated to: {}", occupyTimeout); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/SampleCountProperty.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/SampleCountProperty.java index 8001a80e..7d70b887 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/SampleCountProperty.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/SampleCountProperty.java @@ -60,6 +60,6 @@ public class SampleCountProperty { SAMPLE_COUNT = newSampleCount; ClusterBuilderSlot.resetClusterNodes(); } - RecordLog.info("SAMPLE_COUNT updated to: " + SAMPLE_COUNT); + RecordLog.info("SAMPLE_COUNT updated to: {}", SAMPLE_COUNT); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricWriter.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricWriter.java index 34745ac0..7f4e230e 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricWriter.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricWriter.java @@ -92,9 +92,8 @@ public class MetricWriter { if (singleFileSize <= 0 || totalFileCount <= 0) { throw new IllegalArgumentException(); } - RecordLog.info( - "[MetricWriter] Creating new MetricWriter, singleFileSize=" + singleFileSize + ", totalFileCount=" - + totalFileCount); + RecordLog.info("[MetricWriter] Creating new MetricWriter, singleFileSize={}, totalFileCount={}", + singleFileSize, totalFileCount); this.baseDir = METRIC_BASE_DIR; File dir = new File(baseDir); if (!dir.exists()) { @@ -328,9 +327,9 @@ public class MetricWriter { String fileName = list.get(i); String indexFile = formIndexFileName(fileName); new File(fileName).delete(); - RecordLog.info("[MetricWriter] Removing metric file: " + fileName); + RecordLog.info("[MetricWriter] Removing metric file: {}", fileName); new File(indexFile).delete(); - RecordLog.info("[MetricWriter] Removing metric index file: " + indexFile); + RecordLog.info("[MetricWriter] Removing metric index file: {}", indexFile); } } @@ -348,8 +347,8 @@ public class MetricWriter { String idxFile = formIndexFileName(fileName); curMetricIndexFile = new File(idxFile); outIndex = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(idxFile, append))); - RecordLog.info("[MetricWriter] New metric file created: " + fileName); - RecordLog.info("[MetricWriter] New metric index file created: " + idxFile); + RecordLog.info("[MetricWriter] New metric file created: {}", fileName); + RecordLog.info("[MetricWriter] New metric index file created: {}", idxFile); } private boolean validSize() throws Exception { diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java index c1437105..b432df71 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java @@ -50,7 +50,7 @@ public class DynamicSentinelProperty implements SentinelProperty { if (isEqual(value, newValue)) { return false; } - RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); + RecordLog.info("[DynamicSentinelProperty] Config will be updated to: {}", newValue); value = newValue; for (PropertyListener listener : listeners) { diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/SlotChainProvider.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/SlotChainProvider.java index 9aabbb33..49ab60a3 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/SlotChainProvider.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slotchain/SlotChainProvider.java @@ -48,8 +48,8 @@ public final class SlotChainProvider { RecordLog.warn("[SlotChainProvider] Wrong state when resolving slot chain builder, using default"); slotChainBuilder = new DefaultSlotChainBuilder(); } else { - RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: " - + slotChainBuilder.getClass().getCanonicalName()); + RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: {}", + slotChainBuilder.getClass().getCanonicalName()); } return slotChainBuilder.build(); } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java index 7962c50e..22b698dd 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java @@ -99,7 +99,7 @@ public final class AuthorityRuleManager { if (rules != null) { authorityRules.putAll(rules); } - RecordLog.info("[AuthorityRuleManager] Authority rules received: " + authorityRules); + RecordLog.info("[AuthorityRuleManager] Authority rules received: {}", authorityRules); } private Map> loadAuthorityConf(List list) { @@ -111,7 +111,7 @@ public final class AuthorityRuleManager { for (AuthorityRule rule : list) { if (!isValidRule(rule)) { - RecordLog.warn("[AuthorityRuleManager] Ignoring invalid authority rule when loading new rules: " + rule); + RecordLog.warn("[AuthorityRuleManager] Ignoring invalid authority rule when loading new rules: {}", rule); continue; } @@ -128,7 +128,7 @@ public final class AuthorityRuleManager { newRuleMap.put(identity, ruleSet); } else { // One resource should only have at most one authority rule, so just ignore redundant rules. - RecordLog.warn("[AuthorityRuleManager] Ignoring redundant rule: " + rule.toString()); + RecordLog.warn("[AuthorityRuleManager] Ignoring redundant rule: {}", rule.toString()); } } @@ -143,7 +143,7 @@ public final class AuthorityRuleManager { if (rules != null) { authorityRules.putAll(rules); } - RecordLog.info("[AuthorityRuleManager] Load authority rules: " + authorityRules); + RecordLog.info("[AuthorityRuleManager] Load authority rules: {}", authorityRules); } } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java index d7d6b6c9..a1214a7b 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java @@ -224,13 +224,13 @@ public final class DegradeRuleManager { @Override public void configUpdate(List conf) { reloadFrom(conf); - RecordLog.info("[DegradeRuleManager] Degrade rules has been updated to: " + ruleMap); + RecordLog.info("[DegradeRuleManager] Degrade rules has been updated to: {}", ruleMap); } @Override public void configLoad(List conf) { reloadFrom(conf); - RecordLog.info("[DegradeRuleManager] Degrade rules loaded: " + ruleMap); + RecordLog.info("[DegradeRuleManager] Degrade rules loaded: {}", ruleMap); } private Map> buildCircuitBreakers(List list) { @@ -240,7 +240,7 @@ public final class DegradeRuleManager { } for (DegradeRule rule : list) { if (!isValidRule(rule)) { - RecordLog.warn("[DegradeRuleManager] Ignoring invalid rule when loading new rules: " + rule); + RecordLog.warn("[DegradeRuleManager] Ignoring invalid rule when loading new rules: {}", rule); continue; } @@ -249,7 +249,7 @@ public final class DegradeRuleManager { } CircuitBreaker cb = getExistingSameCbOrNew(rule); if (cb == null) { - RecordLog.warn("[DegradeRuleManager] Unknown circuit breaking strategy, ignoring: " + rule); + RecordLog.warn("[DegradeRuleManager] Unknown circuit breaking strategy, ignoring: {}", rule); continue; } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java index 40d2f92a..fc733aef 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java @@ -133,7 +133,7 @@ public class FlowRuleManager { flowRules.clear(); flowRules.putAll(rules); } - RecordLog.info("[FlowRuleManager] Flow rules received: " + flowRules); + RecordLog.info("[FlowRuleManager] Flow rules received: {}", flowRules); } @Override @@ -143,7 +143,7 @@ public class FlowRuleManager { flowRules.clear(); flowRules.putAll(rules); } - RecordLog.info("[FlowRuleManager] Flow rules loaded: " + flowRules); + RecordLog.info("[FlowRuleManager] Flow rules loaded: {}", flowRules); } } diff --git a/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java b/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java index 97d572e7..598b5bf8 100644 --- a/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java +++ b/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java @@ -53,7 +53,7 @@ public class ApolloDataSource extends AbstractDataSource { initialize(); - RecordLog.info(String.format("Initialized rule for namespace: %s, rule key: %s", namespaceName, ruleKey)); + RecordLog.info("Initialized rule for namespace: {}, rule key: {}", namespaceName, ruleKey); } private void initialize() { @@ -80,7 +80,7 @@ public class ApolloDataSource extends AbstractDataSource { ConfigChange change = changeEvent.getChange(ruleKey); //change is never null because the listener will only notify for this key if (change != null) { - RecordLog.info("[ApolloDataSource] Received config changes: " + change.toString()); + RecordLog.info("[ApolloDataSource] Received config changes: {}", change); } loadAndUpdateRules(); } diff --git a/sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/FileWritableDataSource.java b/sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/FileWritableDataSource.java index 963a4345..7e06a9cb 100644 --- a/sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/FileWritableDataSource.java +++ b/sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/FileWritableDataSource.java @@ -73,7 +73,7 @@ public class FileWritableDataSource implements WritableDataSource { outputStream = new FileOutputStream(file); byte[] bytesArray = convertResult.getBytes(charset); - RecordLog.info(String.format("[FileWritableDataSource] Writing to file %s: %s", file.toString(), convertResult)); + RecordLog.info("[FileWritableDataSource] Writing to file {}: {}", file, convertResult); outputStream.write(bytesArray); outputStream.flush(); } finally { diff --git a/sentinel-extension/sentinel-datasource-nacos/src/main/java/com/alibaba/csp/sentinel/datasource/nacos/NacosDataSource.java b/sentinel-extension/sentinel-datasource-nacos/src/main/java/com/alibaba/csp/sentinel/datasource/nacos/NacosDataSource.java index f7b47276..f6604566 100644 --- a/sentinel-extension/sentinel-datasource-nacos/src/main/java/com/alibaba/csp/sentinel/datasource/nacos/NacosDataSource.java +++ b/sentinel-extension/sentinel-datasource-nacos/src/main/java/com/alibaba/csp/sentinel/datasource/nacos/NacosDataSource.java @@ -99,8 +99,8 @@ public class NacosDataSource extends AbstractDataSource { @Override public void receiveConfigInfo(final String configInfo) { - RecordLog.info(String.format("[NacosDataSource] New property value received for (properties: %s) (dataId: %s, groupId: %s): %s", - properties, dataId, groupId, configInfo)); + RecordLog.info("[NacosDataSource] New property value received for (properties: {}) (dataId: {}, groupId: {}): {}", + properties, dataId, groupId, configInfo); T newValue = NacosDataSource.this.parser.convert(configInfo); // Update the new value to the property. getProperty().updateValue(newValue); diff --git a/sentinel-extension/sentinel-datasource-redis/src/main/java/com/alibaba/csp/sentinel/datasource/redis/RedisDataSource.java b/sentinel-extension/sentinel-datasource-redis/src/main/java/com/alibaba/csp/sentinel/datasource/redis/RedisDataSource.java index aa5a38a5..c0e3e45b 100644 --- a/sentinel-extension/sentinel-datasource-redis/src/main/java/com/alibaba/csp/sentinel/datasource/redis/RedisDataSource.java +++ b/sentinel-extension/sentinel-datasource-redis/src/main/java/com/alibaba/csp/sentinel/datasource/redis/RedisDataSource.java @@ -172,7 +172,7 @@ public class RedisDataSource extends AbstractDataSource { @Override public void message(String channel, String message) { - RecordLog.info(String.format("[RedisDataSource] New property value received for channel %s: %s", channel, message)); + RecordLog.info("[RedisDataSource] New property value received for channel {}: {}", channel, message); getProperty().updateValue(parser.convert(message)); } } diff --git a/sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SentinelRuleLocator.java b/sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SentinelRuleLocator.java index 3ef83c80..fdbdae6b 100644 --- a/sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SentinelRuleLocator.java +++ b/sentinel-extension/sentinel-datasource-spring-cloud-config/src/main/java/com/alibaba/csp/sentinel/datasource/spring/cloud/config/SentinelRuleLocator.java @@ -147,11 +147,10 @@ public class SentinelRuleLocator implements PropertySourceLocator { private void log(Environment result) { - RecordLog.info(String.format( - "Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s", + RecordLog.info("Located environment: name={}, profiles={}, label={}, version={}, state={}", result.getName(), result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), - result.getLabel(), result.getVersion(), result.getState())); + result.getLabel(), result.getVersion(), result.getState()); List propertySourceList = result.getPropertySources(); if (propertySourceList != null) { @@ -194,7 +193,7 @@ public class SentinelRuleLocator implements PropertySourceLocator { String username = credentials.getUsername(); String password = credentials.getPassword(); - RecordLog.info("[SentinelRuleLocator] Fetching config from server at: " + uri); + RecordLog.info("[SentinelRuleLocator] Fetching config from server at: {}", uri); try { HttpHeaders headers = new HttpHeaders(); diff --git a/sentinel-extension/sentinel-datasource-zookeeper/src/main/java/com/alibaba/csp/sentinel/datasource/zookeeper/ZookeeperDataSource.java b/sentinel-extension/sentinel-datasource-zookeeper/src/main/java/com/alibaba/csp/sentinel/datasource/zookeeper/ZookeeperDataSource.java index 5fb243bb..2ff66aa2 100644 --- a/sentinel-extension/sentinel-datasource-zookeeper/src/main/java/com/alibaba/csp/sentinel/datasource/zookeeper/ZookeeperDataSource.java +++ b/sentinel-extension/sentinel-datasource-zookeeper/src/main/java/com/alibaba/csp/sentinel/datasource/zookeeper/ZookeeperDataSource.java @@ -110,8 +110,8 @@ public class ZookeeperDataSource extends AbstractDataSource { try { T newValue = loadConfig(); - RecordLog.info(String.format("[ZookeeperDataSource] New property value received for (%s, %s): %s", - serverAddr, path, newValue)); + RecordLog.info("[ZookeeperDataSource] New property value received for ({}, {}): {}", + serverAddr, path, newValue); // Update the new value to the property. getProperty().updateValue(newValue); } catch (Exception ex) { diff --git a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyParamFlowRulesCommandHandler.java b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyParamFlowRulesCommandHandler.java index b8428aee..2022b16b 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyParamFlowRulesCommandHandler.java +++ b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/command/handler/ModifyParamFlowRulesCommandHandler.java @@ -51,7 +51,7 @@ public class ModifyParamFlowRulesCommandHandler implements CommandHandler flowRules = JSONArray.parseArray(data, ParamFlowRule.class); diff --git a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManager.java b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManager.java index b660e0d9..1f1ebf81 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManager.java +++ b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManager.java @@ -105,7 +105,7 @@ public final class ParamFlowRuleManager { PARAM_FLOW_RULES.clear(); PARAM_FLOW_RULES.putAll(rules); } - RecordLog.info("[ParamFlowRuleManager] Parameter flow rules received: " + PARAM_FLOW_RULES); + RecordLog.info("[ParamFlowRuleManager] Parameter flow rules received: {}", PARAM_FLOW_RULES); } @Override @@ -115,7 +115,7 @@ public final class ParamFlowRuleManager { PARAM_FLOW_RULES.clear(); PARAM_FLOW_RULES.putAll(rules); } - RecordLog.info("[ParamFlowRuleManager] Parameter flow rules received: " + PARAM_FLOW_RULES); + RecordLog.info("[ParamFlowRuleManager] Parameter flow rules received: {}", PARAM_FLOW_RULES); } private Map> aggregateAndPrepareParamRules(List list) { diff --git a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetricStorage.java b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetricStorage.java index 5b531bfa..4eb58f90 100644 --- a/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetricStorage.java +++ b/sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParameterMetricStorage.java @@ -54,7 +54,7 @@ public final class ParameterMetricStorage { if ((metric = metricsMap.get(resourceName)) == null) { metric = new ParameterMetric(); metricsMap.put(resourceWrapper.getName(), metric); - RecordLog.info("[ParameterMetricStorage] Creating parameter metric for: " + resourceWrapper.getName()); + RecordLog.info("[ParameterMetricStorage] Creating parameter metric for: {}", resourceWrapper.getName()); } } } @@ -80,7 +80,7 @@ public final class ParameterMetricStorage { return; } metricsMap.remove(resourceName); - RecordLog.info("[ParameterMetricStorage] Clearing parameter metric for: " + resourceName); + RecordLog.info("[ParameterMetricStorage] Clearing parameter metric for: {}", resourceName); } static Map getMetricsMap() { diff --git a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandCenterProvider.java b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandCenterProvider.java index 12bb1713..8d94e630 100644 --- a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandCenterProvider.java +++ b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/CommandCenterProvider.java @@ -40,7 +40,7 @@ public final class CommandCenterProvider { RecordLog.warn("[CommandCenterProvider] WARN: No existing CommandCenter found"); } else { commandCenter = resolveCommandCenter; - RecordLog.info("[CommandCenterProvider] CommandCenter resolved: " + resolveCommandCenter.getClass() + RecordLog.info("[CommandCenterProvider] CommandCenter resolved: {}", resolveCommandCenter.getClass() .getCanonicalName()); } } diff --git a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/cluster/ModifyClusterModeCommandHandler.java b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/cluster/ModifyClusterModeCommandHandler.java index bad05134..79cb1d3d 100644 --- a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/cluster/ModifyClusterModeCommandHandler.java +++ b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/cluster/ModifyClusterModeCommandHandler.java @@ -41,7 +41,7 @@ public class ModifyClusterModeCommandHandler implements CommandHandler { if (mode == ClusterStateManager.CLUSTER_SERVER && !isClusterServerSpiAvailable()) { return CommandResponse.ofFailure(new IllegalStateException("token server mode not available: no SPI found")); } - RecordLog.info("[ModifyClusterModeCommandHandler] Modifying cluster mode to: " + mode); + RecordLog.info("[ModifyClusterModeCommandHandler] Modifying cluster mode to: {}", mode); ClusterStateManager.applyState(mode); return CommandResponse.ofSuccess("success"); diff --git a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/heartbeat/HeartbeatSenderProvider.java b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/heartbeat/HeartbeatSenderProvider.java index c1d04f5c..57b68662 100644 --- a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/heartbeat/HeartbeatSenderProvider.java +++ b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/heartbeat/HeartbeatSenderProvider.java @@ -37,7 +37,7 @@ public final class HeartbeatSenderProvider { RecordLog.warn("[HeartbeatSenderProvider] WARN: No existing HeartbeatSender found"); } else { heartbeatSender = resolved; - RecordLog.info("[HeartbeatSenderProvider] HeartbeatSender activated: " + resolved.getClass() + RecordLog.info("[HeartbeatSenderProvider] HeartbeatSender activated: {}", resolved.getClass() .getCanonicalName()); } } diff --git a/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java b/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java index 52afbf8f..c684156e 100755 --- a/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java +++ b/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java @@ -67,8 +67,7 @@ public class HttpHeartbeatSender implements HeartbeatSender { } else { consoleHost = dashboardList.get(0).r1; consolePort = dashboardList.get(0).r2; - RecordLog.info( - "[NettyHttpHeartbeatSender] Dashboard address parsed: <" + consoleHost + ':' + consolePort + ">"); + RecordLog.info("[NettyHttpHeartbeatSender] Dashboard address parsed: <{}:{}>", consoleHost, consolePort); } } diff --git a/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/SimpleHttpHeartbeatSender.java b/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/SimpleHttpHeartbeatSender.java index 7626dae0..a8b82e9a 100755 --- a/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/SimpleHttpHeartbeatSender.java +++ b/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/SimpleHttpHeartbeatSender.java @@ -52,7 +52,7 @@ public class SimpleHttpHeartbeatSender implements HeartbeatSender { if (newAddrs.isEmpty()) { RecordLog.warn("[SimpleHttpHeartbeatSender] Dashboard server address not configured or not available"); } else { - RecordLog.info("[SimpleHttpHeartbeatSender] Default console address list retrieved: " + newAddrs); + RecordLog.info("[SimpleHttpHeartbeatSender] Default console address list retrieved: {}", newAddrs); } this.addressList = newAddrs; }