Added logging messages

This commit is contained in:
Marcin Grzejszczak
2018-03-31 17:41:30 +02:00
parent c36c630412
commit b238a3e835

View File

@@ -19,6 +19,8 @@ package org.springframework.cloud.contract.stubrunner;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.StringUtils;
/**
@@ -29,6 +31,8 @@ import org.springframework.util.StringUtils;
*/
class StubRunnerPropertyUtils {
private static final Log log = LogFactory.getLog(StubRunnerPropertyUtils.class);
private static final String STUBRUNNER_PROPERTIES = "stubrunner.properties";
static PropertyFetcher FETCHER = new PropertyFetcher();
@@ -48,7 +52,11 @@ class StubRunnerPropertyUtils {
*/
static String getProperty(Map<String, String> options, String propName) {
if (options != null && options.containsKey(propName)) {
return options.get(propName);
String value = options.get(propName);
if (log.isDebugEnabled()) {
log.debug("Options map contains the prop [" + propName + "] with value [" + value + "]");
}
return value;
}
String directTry = doGetProp(propName);
if (StringUtils.hasText(directTry)) {
@@ -60,11 +68,18 @@ class StubRunnerPropertyUtils {
private static String doGetProp(String stubRunnerProp) {
String systemProp = FETCHER.systemProp(stubRunnerProp);
if (StringUtils.hasText(systemProp)) {
if (log.isDebugEnabled()) {
log.debug("System property [" + stubRunnerProp + "] has value [" + systemProp + "]");
}
return systemProp;
}
String convertedEnvProp = stubRunnerProp.replaceAll("\\.", "_")
.replaceAll("-", "_").toUpperCase();
return FETCHER.envVar(convertedEnvProp);
String envVar = FETCHER.envVar(convertedEnvProp);
if (log.isDebugEnabled()) {
log.debug("Environment variable [" + convertedEnvProp + "] has value [" + envVar + "]");
}
return envVar;
}
}