From 9d99292d5973b3d51ea57bbdd302516c367f6f21 Mon Sep 17 00:00:00 2001 From: godhth <1165559068@qq.com> Date: Mon, 19 Feb 2024 17:27:53 +0800 Subject: [PATCH] log improvement --- .../control/connection/ConnectionControlManager.java | 8 +++----- .../connection/DefaultConnectionControlManager.java | 4 ++-- .../plugin/control/rule/ControlRuleChangeActivator.java | 8 ++++---- .../plugin/control/rule/storage/LocalDiskRuleStorage.java | 2 +- .../nacos/plugin/control/tps/TpsControlManager.java | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/ConnectionControlManager.java b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/ConnectionControlManager.java index 026d05b78d2..7224d12271d 100644 --- a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/ConnectionControlManager.java +++ b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/ConnectionControlManager.java @@ -93,8 +93,8 @@ private void initConnectionRule() { && ruleStorageProxy.getExternalStorage().getConnectionRule() != null) { localRuleContent = ruleStorageProxy.getExternalStorage().getConnectionRule(); if (StringUtils.isNotBlank(localRuleContent)) { - Loggers.CONTROL - .info("Found persist disk connection rule content on start up ,value ={}", localRuleContent); + Loggers.CONTROL.info("Found persist disk connection rule content on start up ,value ={}", + localRuleContent); } } @@ -139,9 +139,7 @@ public void run() { Collectors.toMap(ConnectionMetricsCollector::getName, ConnectionMetricsCollector::getTotalCount)); int totalCount = metricsTotalCount.values().stream().mapToInt(Integer::intValue).sum(); - Loggers.CONNECTION.info(String.format("ConnectionMetrics, totalCount = %s, detail = %s", totalCount, - metricsTotalCount.toString())); - + Loggers.CONNECTION.info("ConnectionMetrics, totalCount = {}, detail = {}", totalCount, metricsTotalCount); } } } diff --git a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/DefaultConnectionControlManager.java b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/DefaultConnectionControlManager.java index 0f2c5d2d696..a8c6586cd96 100644 --- a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/DefaultConnectionControlManager.java +++ b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/connection/DefaultConnectionControlManager.java @@ -42,8 +42,8 @@ public DefaultConnectionControlManager() { @Override public void applyConnectionLimitRule(ConnectionControlRule connectionControlRule) { super.connectionControlRule = connectionControlRule; - Loggers.CONTROL.info("Connection control rule updated to ->" + (this.connectionControlRule == null ? null - : JacksonUtils.toJson(this.connectionControlRule))); + Loggers.CONTROL.info("Connection control rule updated to -> {}", + (this.connectionControlRule == null ? null : JacksonUtils.toJson(this.connectionControlRule))); Loggers.CONTROL.warn("Connection control updated, But connection control manager is no limit implementation."); } diff --git a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/ControlRuleChangeActivator.java b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/ControlRuleChangeActivator.java index 9e8fb4c8b78..27a35088d7d 100644 --- a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/ControlRuleChangeActivator.java +++ b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/ControlRuleChangeActivator.java @@ -67,9 +67,9 @@ public void onEvent(TpsControlRuleChangeEvent event) { String persistTpsRule = ruleStorageProxy.getExternalStorage().getTpsRule(pointName); ruleStorageProxy.getLocalDiskStorage().saveTpsRule(pointName, persistTpsRule); } else { - Loggers.CONTROL - .info("No external rule storage found,will load local disk instead,point name={}", - event.getPointName()); + Loggers.CONTROL.info( + "No external rule storage found,will load local disk instead,point name={}", + event.getPointName()); } } @@ -114,7 +114,7 @@ public void onEvent(ConnectionLimitRuleChangeEvent event) { } String limitRule = ruleStorageProxy.getLocalDiskStorage().getConnectionRule(); - Loggers.CONTROL.info("start to apply connection rule content " + limitRule); + Loggers.CONTROL.info("start to apply connection rule content {}", limitRule); ConnectionControlManager controlManager = ControlManagerCenter.getInstance() .getConnectionControlManager(); ConnectionControlRule connectionControlRule = diff --git a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/storage/LocalDiskRuleStorage.java b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/storage/LocalDiskRuleStorage.java index 8b586b79928..f9d93b2512e 100644 --- a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/storage/LocalDiskRuleStorage.java +++ b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/rule/storage/LocalDiskRuleStorage.java @@ -76,7 +76,7 @@ public void saveConnectionRule(String ruleContent) throws IOException { pointFile.createNewFile(); } DiskUtils.writeFile(pointFile, ruleContent.getBytes(Constants.ENCODE), false); - LOGGER.info("Save connection rule to local,pointName={}, ruleContent ={} ", ruleContent); + LOGGER.info("Save connection rule to local, ruleContent ={} ", ruleContent); } @Override diff --git a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/tps/TpsControlManager.java b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/tps/TpsControlManager.java index c7586b1060a..4b41ba74b17 100644 --- a/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/tps/TpsControlManager.java +++ b/plugin/control/src/main/java/com/alibaba/nacos/plugin/control/tps/TpsControlManager.java @@ -82,7 +82,7 @@ protected void initTpsRule(String pointName) { TpsControlRule tpsLimitRule = tpsControlRuleParser.parseRule(localRuleContent); this.applyTpsRule(pointName, tpsLimitRule); } else { - Loggers.CONTROL.info("No tps control rule of {} found ", pointName, localRuleContent); + Loggers.CONTROL.info("No tps control rule of {} found,content ={} ", pointName, localRuleContent); } }