-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[weatherunderground] Log URL with masked API key #7756
Conversation
Relative to openhab#3990 Signed-off-by: Laurent Garnier <[email protected]>
Travis tests were successfulHey @lolodomo, |
.../java/org/openhab/binding/weatherunderground/internal/handler/WeatherUndergroundHandler.java
Show resolved
Hide resolved
@@ -553,7 +551,9 @@ private boolean updateWeatherData(Set<String> features) { | |||
} | |||
|
|||
urlStr = urlStr.replace("%QUERY%", StringUtils.trimToEmpty(config.location)); | |||
logger.debug("URL = {}", urlStr); | |||
logger.debug("URL = {}", urlStr.replace("%APIKEY%", "***")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.debug("URL = {}", urlStr.replace("%APIKEY%", "***")); | |
if(logger.isDebugEnabled()){ | |
logger.debug("URL = {}", urlStr.replace("%APIKEY%", "***")); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the interest to add this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since users may not be interested in debug logging, and as such would be filtered out, you should try to minimize wasting computational resources on creating values to be logged.
In this case String.replace
involves a search and replace, the result of which might not even be used. So in order to prevent unnecessary calls to this operation we just check if that logging level is even enabled in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done.
Signed-off-by: Laurent Garnier <[email protected]>
Travis tests were successfulHey @lolodomo, |
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]> Signed-off-by: CSchlipp <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
* [weatherunderground] Log URL with masked API key Relative to openhab#3990 * Add isDebugEnabled Signed-off-by: Laurent Garnier <[email protected]>
Relative to #3990
Signed-off-by: Laurent Garnier [email protected]