From 94d9b39b42a2aed47e2169f0a40e12a0d4e25ba3 Mon Sep 17 00:00:00 2001 From: Florian Hopf Date: Tue, 27 Feb 2018 11:01:15 +0800 Subject: [PATCH] tabs instead of spaces, checking for log level --- .../ConfigServicePropertySourceLocator.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java index 5a09af09..11fdd8f4 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java @@ -138,24 +138,26 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator } private void log(Environment result) { - logger.info(String.format("Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s", - result.getName(), - result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), - result.getLabel(), result.getVersion(), result.getState())); + if (logger.isInfoEnabled()) { + logger.info(String.format("Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s", + result.getName(), + result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), + result.getLabel(), result.getVersion(), result.getState())); + } if (logger.isDebugEnabled()) { - List propertySourceList = result.getPropertySources(); - if (propertySourceList != null) { - int propertyCount = 0; - for (PropertySource propertySource: propertySourceList) { - propertyCount += propertySource.getSource().size(); - } - logger.debug(String.format("Environment %s has %d property sources with %d properties.", - result.getName(), - result.getPropertySources().size(), - propertyCount)); - } + List propertySourceList = result.getPropertySources(); + if (propertySourceList != null) { + int propertyCount = 0; + for (PropertySource propertySource: propertySourceList) { + propertyCount += propertySource.getSource().size(); + } + logger.debug(String.format("Environment %s has %d property sources with %d properties.", + result.getName(), + result.getPropertySources().size(), + propertyCount)); + } - } + } } private void putValue(HashMap map, String key, String value) {