Changeset 15389 in josm
- Timestamp:
- 2019-09-29T22:47:44+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r15233 r15389 69 69 private Response response; 70 70 private boolean finishOnCloseOutput = true; 71 private boolean debug; 71 72 72 73 // Pattern to detect Tomcat error message. Be careful with change of format: … … 142 143 cr = performConnection(); 143 144 final boolean hasReason = reasonForRequest != null && !reasonForRequest.isEmpty(); 144 Logging.info("{0} {1}{2} -> {3} {4}{5}",145 logRequest("{0} {1}{2} -> {3} {4}{5}", 145 146 getRequestMethod(), getURL(), hasReason ? (" (" + reasonForRequest + ')') : "", 146 147 cr.getResponseVersion(), cr.getResponseCode(), … … 160 161 } 161 162 } catch (IOException | RuntimeException e) { 162 Logging.info("{0} {1} -> !!!", requestMethod, url);163 logRequest("{0} {1} -> !!!", requestMethod, url); 163 164 Logging.warn(e); 164 165 //noinspection ThrowableResultOfMethodCallIgnored … … 175 176 url = new URL(url, redirectLocation); 176 177 maxRedirects--; 177 Logging.info(tr("Download redirected to ''{0}''", redirectLocation));178 logRequest(tr("Download redirected to ''{0}''", redirectLocation)); 178 179 response = connect(); 179 180 successfulConnection = true; … … 207 208 } 208 209 210 protected final void logRequest(String pattern, Object... args) { 211 if (debug) { 212 Logging.debug(pattern, args); 213 } else { 214 Logging.info(pattern, args); 215 } 216 } 217 209 218 protected final void logRequestBody() { 210 Logging.info("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault()));219 logRequest("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault())); 211 220 if (Logging.isTraceEnabled() && hasRequestBody()) { 212 221 Logging.trace("BODY: {0}", new String(requestBody, StandardCharsets.UTF_8)); … … 801 810 } 802 811 812 /** 813 * Sets the connect log at DEBUG level instead of the default INFO level. 814 * @param debug {@code true} to set the connect log at DEBUG level 815 * @return {@code this} 816 * @since 15389 817 */ 818 public final HttpClient setLogAtDebug(boolean debug) { 819 this.debug = debug; 820 return this; 821 } 822 803 823 private static boolean isRedirect(final int statusCode) { 804 824 switch (statusCode) {
Note:
See TracChangeset
for help on using the changeset viewer.