Skip to content

Commit

Permalink
[weatherunderground] Log URL with masked API key (openhab#7756)
Browse files Browse the repository at this point in the history
* [weatherunderground] Log URL with masked API key

Relative to openhab#3990
* Add isDebugEnabled

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
  • Loading branch information
lolodomo authored and CSchlipp committed Jul 26, 2020
1 parent 43ff396 commit 4147dbf
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,7 @@ private boolean updateWeatherData(Set<String> features) {
try {
WeatherUndergroundConfiguration config = getConfigAs(WeatherUndergroundConfiguration.class);

String urlStr = URL_QUERY.replace("%APIKEY%", StringUtils.trimToEmpty(bridgeHandler.getApikey()));

urlStr = urlStr.replace("%FEATURES%", String.join("/", features));
String urlStr = URL_QUERY.replace("%FEATURES%", String.join("/", features));

String lang = StringUtils.trimToEmpty(config.language);
if (lang.isEmpty()) {
Expand All @@ -553,7 +551,11 @@ private boolean updateWeatherData(Set<String> features) {
}

urlStr = urlStr.replace("%QUERY%", StringUtils.trimToEmpty(config.location));
logger.debug("URL = {}", urlStr);
if (logger.isDebugEnabled()) {
logger.debug("URL = {}", urlStr.replace("%APIKEY%", "***"));
}

urlStr = urlStr.replace("%APIKEY%", StringUtils.trimToEmpty(bridgeHandler.getApikey()));

// Run the HTTP request and get the JSON response from Weather Underground
String response = null;
Expand Down

0 comments on commit 4147dbf

Please sign in to comment.