Optimize logging statements using placeholder (#1736)

* Optimize logging statements using placeholder to avoid unnecessary concatenation (issue #1735)
This commit is contained in:
nickChenyx 2020-09-17 20:42:01 +08:00 committed by GitHub
parent 7192bcfb5b
commit cc2d1a69a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 97 additions and 102 deletions

View File

@ -62,8 +62,8 @@ public final class GatewayApiDefinitionManager {
List<ApiDefinitionChangeObserver> listeners = SpiLoader.loadInstanceList(ApiDefinitionChangeObserver.class); List<ApiDefinitionChangeObserver> listeners = SpiLoader.loadInstanceList(ApiDefinitionChangeObserver.class);
for (ApiDefinitionChangeObserver e : listeners) { for (ApiDefinitionChangeObserver e : listeners) {
API_CHANGE_OBSERVERS.put(e.getClass().getCanonicalName(), e); API_CHANGE_OBSERVERS.put(e.getClass().getCanonicalName(), e);
RecordLog.info("[GatewayApiDefinitionManager] ApiDefinitionChangeObserver added: " RecordLog.info("[GatewayApiDefinitionManager] ApiDefinitionChangeObserver added: {}"
+ e.getClass().getCanonicalName()); , e.getClass().getCanonicalName());
} }
} }
@ -103,13 +103,13 @@ public final class GatewayApiDefinitionManager {
@Override @Override
public void configUpdate(Set<ApiDefinition> set) { public void configUpdate(Set<ApiDefinition> set) {
applyApiUpdateInternal(set); applyApiUpdateInternal(set);
RecordLog.info("[GatewayApiDefinitionManager] Api definition updated: " + API_MAP); RecordLog.info("[GatewayApiDefinitionManager] Api definition updated: {}", API_MAP);
} }
@Override @Override
public void configLoad(Set<ApiDefinition> set) { public void configLoad(Set<ApiDefinition> set) {
applyApiUpdateInternal(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<ApiDefinition> set) { private static synchronized void applyApiUpdateInternal(Set<ApiDefinition> set) {

View File

@ -51,7 +51,7 @@ public class UpdateGatewayRuleCommandHandler implements CommandHandler<String> {
return CommandResponse.ofFailure(e, "decode gateway rule data error"); 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; String result = SUCCESS_MSG;
Set<GatewayFlowRule> flowRules = JSON.parseObject(data, new TypeReference<Set<GatewayFlowRule>>() { Set<GatewayFlowRule> flowRules = JSON.parseObject(data, new TypeReference<Set<GatewayFlowRule>>() {

View File

@ -149,13 +149,13 @@ public final class GatewayRuleManager {
@Override @Override
public void configUpdate(Set<GatewayFlowRule> conf) { public void configUpdate(Set<GatewayFlowRule> conf) {
applyGatewayRuleInternal(conf); applyGatewayRuleInternal(conf);
RecordLog.info("[GatewayRuleManager] Gateway flow rules received: " + GATEWAY_RULE_MAP); RecordLog.info("[GatewayRuleManager] Gateway flow rules received: {}", GATEWAY_RULE_MAP);
} }
@Override @Override
public void configLoad(Set<GatewayFlowRule> conf) { public void configLoad(Set<GatewayFlowRule> conf) {
applyGatewayRuleInternal(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<String, Integer> idxMap, String resourceName) { private int getIdxInternal(Map<String, Integer> idxMap, String resourceName) {
@ -271,7 +271,7 @@ public final class GatewayRuleManager {
CONVERTED_PARAM_RULE_MAP.clear(); CONVERTED_PARAM_RULE_MAP.clear();
CONVERTED_PARAM_RULE_MAP.putAll(newRuleMap); 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);
} }
} }
} }

View File

@ -79,7 +79,7 @@ public class DefaultClusterTokenClient implements ClusterTokenClient {
try { try {
this.transportClient = new NettyTransportClient(host, port); this.transportClient = new NettyTransportClient(host, port);
this.serverDescriptor = new TokenServerDescriptor(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) { } catch (Exception ex) {
RecordLog.warn("[DefaultClusterTokenClient] Failed to initialize new token client", 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.transportClient = new NettyTransportClient(config.getServerHost(), config.getServerPort());
this.serverDescriptor = new TokenServerDescriptor(config.getServerHost(), config.getServerPort()); this.serverDescriptor = new TokenServerDescriptor(config.getServerHost(), config.getServerPort());
startClientIfScheduled(); startClientIfScheduled();
RecordLog.info("[DefaultClusterTokenClient] New client created: " + serverDescriptor); RecordLog.info("[DefaultClusterTokenClient] New client created: {}", serverDescriptor);
} catch (Exception ex) { } catch (Exception ex) {
RecordLog.warn("[DefaultClusterTokenClient] Failed to change remote token server", ex); RecordLog.warn("[DefaultClusterTokenClient] Failed to change remote token server", ex);
} }

View File

@ -126,8 +126,7 @@ public class NettyTransportClient implements ClusterTransportClient {
} else { } else {
failConnectedTime.set(0); failConnectedTime.set(0);
channel = future.channel(); channel = future.channel();
RecordLog.info( RecordLog.info("[NettyTransportClient] Successfully connect to server <{}:{}>", host, port);
"[NettyTransportClient] Successfully connect to server <" + host + ":" + port + ">");
} }
} }
}); });
@ -144,7 +143,7 @@ public class NettyTransportClient implements ClusterTransportClient {
@Override @Override
public void run() { public void run() {
if (shouldRetry.get()) { if (shouldRetry.get()) {
RecordLog.info("[NettyTransportClient] Reconnecting to server <" + host + ":" + port + ">"); RecordLog.info("[NettyTransportClient] Reconnecting to server <{}:{}>", host, port);
try { try {
startInternal(); startInternal();
} catch (Exception e) { } catch (Exception e) {

View File

@ -39,14 +39,16 @@ public final class ClientEntityCodecProvider {
RecordLog.warn("[ClientEntityCodecProvider] No existing request entity writer, resolve failed"); RecordLog.warn("[ClientEntityCodecProvider] No existing request entity writer, resolve failed");
} else { } else {
requestEntityWriter = writer; 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); ResponseEntityDecoder decoder = SpiLoader.loadFirstInstance(ResponseEntityDecoder.class);
if (decoder == null) { if (decoder == null) {
RecordLog.warn("[ClientEntityCodecProvider] No existing response entity decoder, resolve failed"); RecordLog.warn("[ClientEntityCodecProvider] No existing response entity decoder, resolve failed");
} else { } else {
responseEntityDecoder = decoder; responseEntityDecoder = decoder;
RecordLog.info("[ClientEntityCodecProvider] Response entity decoder resolved: " + responseEntityDecoder.getClass().getCanonicalName()); RecordLog.info("[ClientEntityCodecProvider] Response entity decoder resolved: {}",
responseEntityDecoder.getClass().getCanonicalName());
} }
} }

View File

@ -131,7 +131,7 @@ public final class ClusterClientConfigManager {
return; return;
} }
RecordLog.info("[ClusterClientConfigManager] Assign to new target token server: " + config); RecordLog.info("[ClusterClientConfigManager] Assign to new target token server: {}", config);
updateServerAssignment(config); updateServerAssignment(config);
} }
@ -156,11 +156,11 @@ public final class ClusterClientConfigManager {
private synchronized void applyConfig(ClusterClientConfig config) { private synchronized void applyConfig(ClusterClientConfig config) {
if (!isValidClientConfig(config)) { if (!isValidClientConfig(config)) {
RecordLog.warn( RecordLog.warn(
"[ClusterClientConfigManager] Invalid cluster client config, ignoring: " + config); "[ClusterClientConfigManager] Invalid cluster client config, ignoring: {}", config);
return; return;
} }
RecordLog.info("[ClusterClientConfigManager] Updating to new client config: " + config); RecordLog.info("[ClusterClientConfigManager] Updating to new client config: {}", config);
updateClientConfigChange(config); updateClientConfigChange(config);
} }

View File

@ -48,7 +48,7 @@ public class TokenClientHandler extends ChannelInboundHandlerAdapter {
public void channelActive(ChannelHandlerContext ctx) throws Exception { public void channelActive(ChannelHandlerContext ctx) throws Exception {
currentState.set(ClientConstants.CLIENT_STATUS_STARTED); currentState.set(ClientConstants.CLIENT_STATUS_STARTED);
fireClientPing(ctx); fireClientPing(ctx);
RecordLog.info("[TokenClientHandler] Client handler active, remote address: " + getRemoteAddress(ctx)); RecordLog.info("[TokenClientHandler] Client handler active, remote address: {}", getRemoteAddress(ctx));
} }
@Override @Override
@ -90,12 +90,12 @@ public class TokenClientHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { 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 @Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { 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); currentState.set(ClientConstants.CLIENT_STATUS_OFF);
disconnectCallback.run(); disconnectCallback.run();

View File

@ -44,7 +44,7 @@ public class ModifyClusterClientConfigHandler implements CommandHandler<String>
} }
try { try {
data = URLDecoder.decode(data, "utf-8"); 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); ClusterClientStateEntity entity = JSON.parseObject(data, ClusterClientStateEntity.class);
ClusterClientConfigManager.applyNewConfig(entity.toClientConfig()); ClusterClientConfigManager.applyNewConfig(entity.toClientConfig());

View File

@ -52,8 +52,8 @@ public final class ConfigSupplierRegistry {
public static void setNamespaceSupplier(Supplier<String> namespaceSupplier) { public static void setNamespaceSupplier(Supplier<String> namespaceSupplier) {
AssertUtil.notNull(namespaceSupplier, "namespaceSupplier cannot be null"); AssertUtil.notNull(namespaceSupplier, "namespaceSupplier cannot be null");
ConfigSupplierRegistry.namespaceSupplier = namespaceSupplier; ConfigSupplierRegistry.namespaceSupplier = namespaceSupplier;
RecordLog.info("[ConfigSupplierRegistry] New namespace supplier provided, current supplied: " RecordLog.info("[ConfigSupplierRegistry] New namespace supplier provided, current supplied: {}",
+ namespaceSupplier.get()); namespaceSupplier.get());
} }
private ConfigSupplierRegistry() {} private ConfigSupplierRegistry() {}

View File

@ -97,7 +97,7 @@ public class RegularExpireStrategy implements ExpireStrategy {
for (int i = 0; i < executeCount && i < keyList.size(); i++) { for (int i = 0; i < executeCount && i < keyList.size(); i++) {
// time out execution exit // time out execution exit
if (System.currentTimeMillis() - start > executeDuration) { 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; break;
} }
Long key = keyList.get(i); Long key = keyList.get(i);

View File

@ -118,7 +118,7 @@ public class NettyTransportServer implements ClusterTokenServer {
RecordLog.info("[NettyTransportServer] Failed to start token server when retrying", e); RecordLog.info("[NettyTransportServer] Failed to start token server when retrying", e);
} }
} else { } 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); currentState.compareAndSet(SERVER_STATUS_STARTING, SERVER_STATUS_STARTED);
} }
} }

View File

@ -39,18 +39,16 @@ public final class ServerEntityCodecProvider {
RecordLog.warn("[ServerEntityCodecProvider] No existing response entity writer, resolve failed"); RecordLog.warn("[ServerEntityCodecProvider] No existing response entity writer, resolve failed");
} else { } else {
responseEntityWriter = writer; responseEntityWriter = writer;
RecordLog.info( RecordLog.info("[ServerEntityCodecProvider] Response entity writer resolved: {}",
"[ServerEntityCodecProvider] Response entity writer resolved: " + responseEntityWriter.getClass() responseEntityWriter.getClass().getCanonicalName());
.getCanonicalName());
} }
RequestEntityDecoder decoder = SpiLoader.loadFirstInstance(RequestEntityDecoder.class); RequestEntityDecoder decoder = SpiLoader.loadFirstInstance(RequestEntityDecoder.class);
if (decoder == null) { if (decoder == null) {
RecordLog.warn("[ServerEntityCodecProvider] No existing request entity decoder, resolve failed"); RecordLog.warn("[ServerEntityCodecProvider] No existing request entity decoder, resolve failed");
} else { } else {
requestEntityDecoder = decoder; requestEntityDecoder = decoder;
RecordLog.info( RecordLog.info("[ServerEntityCodecProvider] Request entity decoder resolved: {}",
"[ServerEntityCodecProvider] Request entity decoder resolved: " + requestEntityDecoder.getClass() requestEntityDecoder.getClass().getCanonicalName());
.getCanonicalName());
} }
} }

View File

@ -46,7 +46,7 @@ public class ModifyClusterServerFlowConfigHandler implements CommandHandler<Stri
data = URLDecoder.decode(data, "utf-8"); data = URLDecoder.decode(data, "utf-8");
if (StringUtil.isEmpty(namespace)) { if (StringUtil.isEmpty(namespace)) {
RecordLog.info("[ModifyClusterServerFlowConfigHandler] Receiving cluster server global flow config: " + data); RecordLog.info("[ModifyClusterServerFlowConfigHandler] Receiving cluster server global flow config: {}", data);
ServerFlowConfig config = JSON.parseObject(data, ServerFlowConfig.class); ServerFlowConfig config = JSON.parseObject(data, ServerFlowConfig.class);
if (!ClusterServerConfigManager.isValidFlowConfig(config)) { if (!ClusterServerConfigManager.isValidFlowConfig(config)) {
CommandResponse.ofFailure(new IllegalArgumentException("Bad flow config")); CommandResponse.ofFailure(new IllegalArgumentException("Bad flow config"));

View File

@ -44,7 +44,7 @@ public class ModifyServerNamespaceSetHandler implements CommandHandler<String> {
} }
try { try {
data = URLDecoder.decode(data, "utf-8"); 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<String> set = JSON.parseObject(data, new TypeReference<Set<String>>() {}); Set<String> set = JSON.parseObject(data, new TypeReference<Set<String>>() {});
ClusterServerConfigManager.loadServerNamespaceSet(set); ClusterServerConfigManager.loadServerNamespaceSet(set);
return CommandResponse.ofSuccess("success"); return CommandResponse.ofSuccess("success");

View File

@ -219,7 +219,7 @@ public final class ClusterServerConfigManager {
if (newSet == null) { if (newSet == null) {
return; 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()) { if (newSet.isEmpty()) {
ClusterServerConfigManager.namespaceSet = Collections.singleton(ServerConstants.DEFAULT_NAMESPACE); ClusterServerConfigManager.namespaceSet = Collections.singleton(ServerConstants.DEFAULT_NAMESPACE);
return; return;
@ -276,10 +276,10 @@ public final class ClusterServerConfigManager {
private synchronized void applyConfig(ServerTransportConfig config) { private synchronized void applyConfig(ServerTransportConfig config) {
if (!isValidTransportConfig(config)) { if (!isValidTransportConfig(config)) {
RecordLog.warn( RecordLog.warn(
"[ClusterServerConfigManager] Invalid cluster server transport config, ignoring: " + config); "[ClusterServerConfigManager] Invalid cluster server transport config, ignoring: {}", config);
return; return;
} }
RecordLog.info("[ClusterServerConfigManager] Updating new server transport config: " + config); RecordLog.info("[ClusterServerConfigManager] Updating new server transport config: {}", config);
if (config.getIdleSeconds() != idleSeconds) { if (config.getIdleSeconds() != idleSeconds) {
idleSeconds = config.getIdleSeconds(); idleSeconds = config.getIdleSeconds();
} }
@ -315,10 +315,10 @@ public final class ClusterServerConfigManager {
private synchronized void applyGlobalFlowConfig(ServerFlowConfig config) { private synchronized void applyGlobalFlowConfig(ServerFlowConfig config) {
if (!isValidFlowConfig(config)) { if (!isValidFlowConfig(config)) {
RecordLog.warn( RecordLog.warn(
"[ClusterServerConfigManager] Invalid cluster server global flow config, ignoring: " + config); "[ClusterServerConfigManager] Invalid cluster server global flow config, ignoring: {}", config);
return; 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) { if (config.getExceedCount() != exceedCount) {
exceedCount = config.getExceedCount(); exceedCount = config.getExceedCount();
} }

View File

@ -31,10 +31,8 @@ public class ScanIdleConnectionTask implements Runnable {
List<Connection> connections = connectionPool.listAllConnection(); List<Connection> connections = connectionPool.listAllConnection();
for (Connection conn : connections) { for (Connection conn : connections) {
if ((now - conn.getLastReadTime()) > idleTimeMillis) { if ((now - conn.getLastReadTime()) > idleTimeMillis) {
RecordLog.info( RecordLog.info("[ScanIdleConnectionTask] The connection <{}:{}> has been idle for <{}>s. It will be closed now.",
String.format("[ScanIdleConnectionTask] The connection <%s:%d> has been idle for <%d>s. " conn.getRemoteIP(), conn.getRemotePort(), idleSeconds);
+ "It will be closed now.", conn.getRemoteIP(), conn.getRemotePort(), idleSeconds)
);
conn.close(); conn.close();
} }
} }

View File

@ -91,7 +91,7 @@ public final class EnvoyRlsRuleManager {
RULE_MAP.clear(); RULE_MAP.clear();
RULE_MAP.putAll(ruleMap); RULE_MAP.putAll(ruleMap);
RecordLog.info("[EnvoyRlsRuleManager] Envoy RLS rules loaded: " + flowRules); RecordLog.info("[EnvoyRlsRuleManager] Envoy RLS rules loaded: {}", flowRules);
// Use the "default" namespace. // Use the "default" namespace.
ClusterFlowRuleManager.loadRules(ServerConstants.DEFAULT_NAMESPACE, flowRules); ClusterFlowRuleManager.loadRules(ServerConstants.DEFAULT_NAMESPACE, flowRules);

View File

@ -44,8 +44,8 @@ public final class TokenClientProvider {
"[TokenClientProvider] No existing cluster token client, cluster client mode will not be activated"); "[TokenClientProvider] No existing cluster token client, cluster client mode will not be activated");
} else { } else {
client = resolvedClient; client = resolvedClient;
RecordLog.info( RecordLog.info("[TokenClientProvider] Cluster token client resolved: {}",
"[TokenClientProvider] Cluster token client resolved: " + client.getClass().getCanonicalName()); client.getClass().getCanonicalName());
} }
} }

View File

@ -36,7 +36,8 @@ public final class EmbeddedClusterTokenServerProvider {
RecordLog.warn("[EmbeddedClusterTokenServerProvider] No existing cluster token server, cluster server mode will not be activated"); RecordLog.warn("[EmbeddedClusterTokenServerProvider] No existing cluster token server, cluster server mode will not be activated");
} else { } else {
server = s; server = s;
RecordLog.info("[EmbeddedClusterTokenServerProvider] Cluster token server resolved: " + server.getClass().getCanonicalName()); RecordLog.info("[EmbeddedClusterTokenServerProvider] Cluster token server resolved: {}",
server.getClass().getCanonicalName());
} }
} }

View File

@ -68,7 +68,7 @@ public final class SentinelConfig {
loadProps(); loadProps();
resolveAppName(); resolveAppName();
resolveAppType(); resolveAppType();
RecordLog.info("[SentinelConfig] Application type resolved: " + appType); RecordLog.info("[SentinelConfig] Application type resolved: {}", appType);
} catch (Throwable ex) { } catch (Throwable ex) {
RecordLog.warn("[SentinelConfig] Failed to initialize", ex); RecordLog.warn("[SentinelConfig] Failed to initialize", ex);
ex.printStackTrace(); ex.printStackTrace();

View File

@ -62,7 +62,7 @@ public final class SentinelConfigLoader {
Properties p = ConfigUtil.loadProperties(fileName); Properties p = ConfigUtil.loadProperties(fileName);
if (p != null && !p.isEmpty()) { if (p != null && !p.isEmpty()) {
RecordLog.info("[SentinelConfigLoader] Loading Sentinel config from " + fileName); RecordLog.info("[SentinelConfigLoader] Loading Sentinel config from {}", fileName);
properties.putAll(p); properties.putAll(p);
} }

View File

@ -46,13 +46,13 @@ public final class InitExecutor {
ServiceLoader<InitFunc> loader = ServiceLoaderUtil.getServiceLoader(InitFunc.class); ServiceLoader<InitFunc> loader = ServiceLoaderUtil.getServiceLoader(InitFunc.class);
List<OrderWrapper> initList = new ArrayList<OrderWrapper>(); List<OrderWrapper> initList = new ArrayList<OrderWrapper>();
for (InitFunc initFunc : loader) { 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); insertSorted(initList, initFunc);
} }
for (OrderWrapper w : initList) { for (OrderWrapper w : initList) {
w.func.init(); w.func.init();
RecordLog.info(String.format("[InitExecutor] Executing %s with order %d", RecordLog.info("[InitExecutor] Executing {} with order {}",
w.func.getClass().getCanonicalName(), w.order)); w.func.getClass().getCanonicalName(), w.order);
} }
} catch (Exception ex) { } catch (Exception ex) {
RecordLog.warn("[InitExecutor] WARN: Initialization failed", ex); RecordLog.warn("[InitExecutor] WARN: Initialization failed", ex);

View File

@ -41,7 +41,7 @@ public class MetricExtensionProvider {
RecordLog.info("[MetricExtensionProvider] No existing MetricExtension found"); RecordLog.info("[MetricExtensionProvider] No existing MetricExtension found");
} else { } else {
metricExtensions.addAll(extensions); metricExtensions.addAll(extensions);
RecordLog.info("[MetricExtensionProvider] MetricExtension resolved, size=" + extensions.size()); RecordLog.info("[MetricExtensionProvider] MetricExtension resolved, size={}", extensions.size());
} }
} }

View File

@ -62,7 +62,7 @@ public class IntervalProperty {
INTERVAL = newInterval; INTERVAL = newInterval;
ClusterBuilderSlot.resetClusterNodes(); ClusterBuilderSlot.resetClusterNodes();
} }
RecordLog.info("[IntervalProperty] INTERVAL updated to: " + INTERVAL); RecordLog.info("[IntervalProperty] INTERVAL updated to: {}", INTERVAL);
} }
} }

View File

@ -67,13 +67,13 @@ public class OccupyTimeoutProperty {
return; return;
} }
if (newInterval > IntervalProperty.INTERVAL) { if (newInterval > IntervalProperty.INTERVAL) {
RecordLog.warn("[OccupyTimeoutProperty] Illegal timeout value will be ignored: " + occupyTimeout RecordLog.warn("[OccupyTimeoutProperty] Illegal timeout value will be ignored: {}, should <= {}",
+ ", should <= " + IntervalProperty.INTERVAL); occupyTimeout, IntervalProperty.INTERVAL);
return; return;
} }
if (newInterval != occupyTimeout) { if (newInterval != occupyTimeout) {
occupyTimeout = newInterval; occupyTimeout = newInterval;
} }
RecordLog.info("[OccupyTimeoutProperty] occupyTimeout updated to: " + occupyTimeout); RecordLog.info("[OccupyTimeoutProperty] occupyTimeout updated to: {}", occupyTimeout);
} }
} }

View File

@ -60,6 +60,6 @@ public class SampleCountProperty {
SAMPLE_COUNT = newSampleCount; SAMPLE_COUNT = newSampleCount;
ClusterBuilderSlot.resetClusterNodes(); ClusterBuilderSlot.resetClusterNodes();
} }
RecordLog.info("SAMPLE_COUNT updated to: " + SAMPLE_COUNT); RecordLog.info("SAMPLE_COUNT updated to: {}", SAMPLE_COUNT);
} }
} }

View File

@ -92,9 +92,8 @@ public class MetricWriter {
if (singleFileSize <= 0 || totalFileCount <= 0) { if (singleFileSize <= 0 || totalFileCount <= 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
RecordLog.info( RecordLog.info("[MetricWriter] Creating new MetricWriter, singleFileSize={}, totalFileCount={}",
"[MetricWriter] Creating new MetricWriter, singleFileSize=" + singleFileSize + ", totalFileCount=" singleFileSize, totalFileCount);
+ totalFileCount);
this.baseDir = METRIC_BASE_DIR; this.baseDir = METRIC_BASE_DIR;
File dir = new File(baseDir); File dir = new File(baseDir);
if (!dir.exists()) { if (!dir.exists()) {
@ -328,9 +327,9 @@ public class MetricWriter {
String fileName = list.get(i); String fileName = list.get(i);
String indexFile = formIndexFileName(fileName); String indexFile = formIndexFileName(fileName);
new File(fileName).delete(); new File(fileName).delete();
RecordLog.info("[MetricWriter] Removing metric file: " + fileName); RecordLog.info("[MetricWriter] Removing metric file: {}", fileName);
new File(indexFile).delete(); 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); String idxFile = formIndexFileName(fileName);
curMetricIndexFile = new File(idxFile); curMetricIndexFile = new File(idxFile);
outIndex = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(idxFile, append))); outIndex = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(idxFile, append)));
RecordLog.info("[MetricWriter] New metric file created: " + fileName); RecordLog.info("[MetricWriter] New metric file created: {}", fileName);
RecordLog.info("[MetricWriter] New metric index file created: " + idxFile); RecordLog.info("[MetricWriter] New metric index file created: {}", idxFile);
} }
private boolean validSize() throws Exception { private boolean validSize() throws Exception {

View File

@ -50,7 +50,7 @@ public class DynamicSentinelProperty<T> implements SentinelProperty<T> {
if (isEqual(value, newValue)) { if (isEqual(value, newValue)) {
return false; return false;
} }
RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); RecordLog.info("[DynamicSentinelProperty] Config will be updated to: {}", newValue);
value = newValue; value = newValue;
for (PropertyListener<T> listener : listeners) { for (PropertyListener<T> listener : listeners) {

View File

@ -48,8 +48,8 @@ public final class SlotChainProvider {
RecordLog.warn("[SlotChainProvider] Wrong state when resolving slot chain builder, using default"); RecordLog.warn("[SlotChainProvider] Wrong state when resolving slot chain builder, using default");
slotChainBuilder = new DefaultSlotChainBuilder(); slotChainBuilder = new DefaultSlotChainBuilder();
} else { } else {
RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: " RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: {}",
+ slotChainBuilder.getClass().getCanonicalName()); slotChainBuilder.getClass().getCanonicalName());
} }
return slotChainBuilder.build(); return slotChainBuilder.build();
} }

View File

@ -99,7 +99,7 @@ public final class AuthorityRuleManager {
if (rules != null) { if (rules != null) {
authorityRules.putAll(rules); authorityRules.putAll(rules);
} }
RecordLog.info("[AuthorityRuleManager] Authority rules received: " + authorityRules); RecordLog.info("[AuthorityRuleManager] Authority rules received: {}", authorityRules);
} }
private Map<String, Set<AuthorityRule>> loadAuthorityConf(List<AuthorityRule> list) { private Map<String, Set<AuthorityRule>> loadAuthorityConf(List<AuthorityRule> list) {
@ -111,7 +111,7 @@ public final class AuthorityRuleManager {
for (AuthorityRule rule : list) { for (AuthorityRule rule : list) {
if (!isValidRule(rule)) { 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; continue;
} }
@ -128,7 +128,7 @@ public final class AuthorityRuleManager {
newRuleMap.put(identity, ruleSet); newRuleMap.put(identity, ruleSet);
} else { } else {
// One resource should only have at most one authority rule, so just ignore redundant rules. // 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) { if (rules != null) {
authorityRules.putAll(rules); authorityRules.putAll(rules);
} }
RecordLog.info("[AuthorityRuleManager] Load authority rules: " + authorityRules); RecordLog.info("[AuthorityRuleManager] Load authority rules: {}", authorityRules);
} }
} }

View File

@ -224,13 +224,13 @@ public final class DegradeRuleManager {
@Override @Override
public void configUpdate(List<DegradeRule> conf) { public void configUpdate(List<DegradeRule> conf) {
reloadFrom(conf); reloadFrom(conf);
RecordLog.info("[DegradeRuleManager] Degrade rules has been updated to: " + ruleMap); RecordLog.info("[DegradeRuleManager] Degrade rules has been updated to: {}", ruleMap);
} }
@Override @Override
public void configLoad(List<DegradeRule> conf) { public void configLoad(List<DegradeRule> conf) {
reloadFrom(conf); reloadFrom(conf);
RecordLog.info("[DegradeRuleManager] Degrade rules loaded: " + ruleMap); RecordLog.info("[DegradeRuleManager] Degrade rules loaded: {}", ruleMap);
} }
private Map<String, List<CircuitBreaker>> buildCircuitBreakers(List<DegradeRule> list) { private Map<String, List<CircuitBreaker>> buildCircuitBreakers(List<DegradeRule> list) {
@ -240,7 +240,7 @@ public final class DegradeRuleManager {
} }
for (DegradeRule rule : list) { for (DegradeRule rule : list) {
if (!isValidRule(rule)) { 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; continue;
} }
@ -249,7 +249,7 @@ public final class DegradeRuleManager {
} }
CircuitBreaker cb = getExistingSameCbOrNew(rule); CircuitBreaker cb = getExistingSameCbOrNew(rule);
if (cb == null) { if (cb == null) {
RecordLog.warn("[DegradeRuleManager] Unknown circuit breaking strategy, ignoring: " + rule); RecordLog.warn("[DegradeRuleManager] Unknown circuit breaking strategy, ignoring: {}", rule);
continue; continue;
} }

View File

@ -133,7 +133,7 @@ public class FlowRuleManager {
flowRules.clear(); flowRules.clear();
flowRules.putAll(rules); flowRules.putAll(rules);
} }
RecordLog.info("[FlowRuleManager] Flow rules received: " + flowRules); RecordLog.info("[FlowRuleManager] Flow rules received: {}", flowRules);
} }
@Override @Override
@ -143,7 +143,7 @@ public class FlowRuleManager {
flowRules.clear(); flowRules.clear();
flowRules.putAll(rules); flowRules.putAll(rules);
} }
RecordLog.info("[FlowRuleManager] Flow rules loaded: " + flowRules); RecordLog.info("[FlowRuleManager] Flow rules loaded: {}", flowRules);
} }
} }

View File

@ -53,7 +53,7 @@ public class ApolloDataSource<T> extends AbstractDataSource<String, T> {
initialize(); 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() { private void initialize() {
@ -80,7 +80,7 @@ public class ApolloDataSource<T> extends AbstractDataSource<String, T> {
ConfigChange change = changeEvent.getChange(ruleKey); ConfigChange change = changeEvent.getChange(ruleKey);
//change is never null because the listener will only notify for this key //change is never null because the listener will only notify for this key
if (change != null) { if (change != null) {
RecordLog.info("[ApolloDataSource] Received config changes: " + change.toString()); RecordLog.info("[ApolloDataSource] Received config changes: {}", change);
} }
loadAndUpdateRules(); loadAndUpdateRules();
} }

View File

@ -73,7 +73,7 @@ public class FileWritableDataSource<T> implements WritableDataSource<T> {
outputStream = new FileOutputStream(file); outputStream = new FileOutputStream(file);
byte[] bytesArray = convertResult.getBytes(charset); 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.write(bytesArray);
outputStream.flush(); outputStream.flush();
} finally { } finally {

View File

@ -99,8 +99,8 @@ public class NacosDataSource<T> extends AbstractDataSource<String, T> {
@Override @Override
public void receiveConfigInfo(final String configInfo) { public void receiveConfigInfo(final String configInfo) {
RecordLog.info(String.format("[NacosDataSource] New property value received for (properties: %s) (dataId: %s, groupId: %s): %s", RecordLog.info("[NacosDataSource] New property value received for (properties: {}) (dataId: {}, groupId: {}): {}",
properties, dataId, groupId, configInfo)); properties, dataId, groupId, configInfo);
T newValue = NacosDataSource.this.parser.convert(configInfo); T newValue = NacosDataSource.this.parser.convert(configInfo);
// Update the new value to the property. // Update the new value to the property.
getProperty().updateValue(newValue); getProperty().updateValue(newValue);

View File

@ -172,7 +172,7 @@ public class RedisDataSource<T> extends AbstractDataSource<String, T> {
@Override @Override
public void message(String channel, String message) { 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)); getProperty().updateValue(parser.convert(message));
} }
} }

View File

@ -147,11 +147,10 @@ public class SentinelRuleLocator implements PropertySourceLocator {
private void log(Environment result) { private void log(Environment result) {
RecordLog.info(String.format( RecordLog.info("Located environment: name={}, profiles={}, label={}, version={}, state={}",
"Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s",
result.getName(), result.getName(),
result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()),
result.getLabel(), result.getVersion(), result.getState())); result.getLabel(), result.getVersion(), result.getState());
List<PropertySource> propertySourceList = result.getPropertySources(); List<PropertySource> propertySourceList = result.getPropertySources();
if (propertySourceList != null) { if (propertySourceList != null) {
@ -194,7 +193,7 @@ public class SentinelRuleLocator implements PropertySourceLocator {
String username = credentials.getUsername(); String username = credentials.getUsername();
String password = credentials.getPassword(); String password = credentials.getPassword();
RecordLog.info("[SentinelRuleLocator] Fetching config from server at: " + uri); RecordLog.info("[SentinelRuleLocator] Fetching config from server at: {}", uri);
try { try {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();

View File

@ -110,8 +110,8 @@ public class ZookeeperDataSource<T> extends AbstractDataSource<String, T> {
try { try {
T newValue = loadConfig(); T newValue = loadConfig();
RecordLog.info(String.format("[ZookeeperDataSource] New property value received for (%s, %s): %s", RecordLog.info("[ZookeeperDataSource] New property value received for ({}, {}): {}",
serverAddr, path, newValue)); serverAddr, path, newValue);
// Update the new value to the property. // Update the new value to the property.
getProperty().updateValue(newValue); getProperty().updateValue(newValue);
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -51,7 +51,7 @@ public class ModifyParamFlowRulesCommandHandler implements CommandHandler<String
return CommandResponse.ofFailure(e, "decode rule data error"); return CommandResponse.ofFailure(e, "decode rule data error");
} }
RecordLog.info(String.format("[API Server] Receiving rule change (type:parameter flow rule): %s", data)); RecordLog.info("[API Server] Receiving rule change (type:parameter flow rule): {}", data);
String result = SUCCESS_MSG; String result = SUCCESS_MSG;
List<ParamFlowRule> flowRules = JSONArray.parseArray(data, ParamFlowRule.class); List<ParamFlowRule> flowRules = JSONArray.parseArray(data, ParamFlowRule.class);

View File

@ -105,7 +105,7 @@ public final class ParamFlowRuleManager {
PARAM_FLOW_RULES.clear(); PARAM_FLOW_RULES.clear();
PARAM_FLOW_RULES.putAll(rules); 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 @Override
@ -115,7 +115,7 @@ public final class ParamFlowRuleManager {
PARAM_FLOW_RULES.clear(); PARAM_FLOW_RULES.clear();
PARAM_FLOW_RULES.putAll(rules); 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<String, List<ParamFlowRule>> aggregateAndPrepareParamRules(List<ParamFlowRule> list) { private Map<String, List<ParamFlowRule>> aggregateAndPrepareParamRules(List<ParamFlowRule> list) {

View File

@ -54,7 +54,7 @@ public final class ParameterMetricStorage {
if ((metric = metricsMap.get(resourceName)) == null) { if ((metric = metricsMap.get(resourceName)) == null) {
metric = new ParameterMetric(); metric = new ParameterMetric();
metricsMap.put(resourceWrapper.getName(), metric); 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; return;
} }
metricsMap.remove(resourceName); metricsMap.remove(resourceName);
RecordLog.info("[ParameterMetricStorage] Clearing parameter metric for: " + resourceName); RecordLog.info("[ParameterMetricStorage] Clearing parameter metric for: {}", resourceName);
} }
static Map<String, ParameterMetric> getMetricsMap() { static Map<String, ParameterMetric> getMetricsMap() {

View File

@ -40,7 +40,7 @@ public final class CommandCenterProvider {
RecordLog.warn("[CommandCenterProvider] WARN: No existing CommandCenter found"); RecordLog.warn("[CommandCenterProvider] WARN: No existing CommandCenter found");
} else { } else {
commandCenter = resolveCommandCenter; commandCenter = resolveCommandCenter;
RecordLog.info("[CommandCenterProvider] CommandCenter resolved: " + resolveCommandCenter.getClass() RecordLog.info("[CommandCenterProvider] CommandCenter resolved: {}", resolveCommandCenter.getClass()
.getCanonicalName()); .getCanonicalName());
} }
} }

View File

@ -41,7 +41,7 @@ public class ModifyClusterModeCommandHandler implements CommandHandler<String> {
if (mode == ClusterStateManager.CLUSTER_SERVER && !isClusterServerSpiAvailable()) { if (mode == ClusterStateManager.CLUSTER_SERVER && !isClusterServerSpiAvailable()) {
return CommandResponse.ofFailure(new IllegalStateException("token server mode not available: no SPI found")); 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); ClusterStateManager.applyState(mode);
return CommandResponse.ofSuccess("success"); return CommandResponse.ofSuccess("success");

View File

@ -37,7 +37,7 @@ public final class HeartbeatSenderProvider {
RecordLog.warn("[HeartbeatSenderProvider] WARN: No existing HeartbeatSender found"); RecordLog.warn("[HeartbeatSenderProvider] WARN: No existing HeartbeatSender found");
} else { } else {
heartbeatSender = resolved; heartbeatSender = resolved;
RecordLog.info("[HeartbeatSenderProvider] HeartbeatSender activated: " + resolved.getClass() RecordLog.info("[HeartbeatSenderProvider] HeartbeatSender activated: {}", resolved.getClass()
.getCanonicalName()); .getCanonicalName());
} }
} }

View File

@ -67,8 +67,7 @@ public class HttpHeartbeatSender implements HeartbeatSender {
} else { } else {
consoleHost = dashboardList.get(0).r1; consoleHost = dashboardList.get(0).r1;
consolePort = dashboardList.get(0).r2; consolePort = dashboardList.get(0).r2;
RecordLog.info( RecordLog.info("[NettyHttpHeartbeatSender] Dashboard address parsed: <{}:{}>", consoleHost, consolePort);
"[NettyHttpHeartbeatSender] Dashboard address parsed: <" + consoleHost + ':' + consolePort + ">");
} }
} }

View File

@ -52,7 +52,7 @@ public class SimpleHttpHeartbeatSender implements HeartbeatSender {
if (newAddrs.isEmpty()) { if (newAddrs.isEmpty()) {
RecordLog.warn("[SimpleHttpHeartbeatSender] Dashboard server address not configured or not available"); RecordLog.warn("[SimpleHttpHeartbeatSender] Dashboard server address not configured or not available");
} else { } else {
RecordLog.info("[SimpleHttpHeartbeatSender] Default console address list retrieved: " + newAddrs); RecordLog.info("[SimpleHttpHeartbeatSender] Default console address list retrieved: {}", newAddrs);
} }
this.addressList = newAddrs; this.addressList = newAddrs;
} }