Ignore:
Timestamp:
2017-08-22T22:26:32+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r12590 r12620  
    111111
    112112        if ("PUT".equals(requestMethod) || "POST".equals(requestMethod) || "DELETE".equals(requestMethod)) {
    113             Main.info("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault()));
     113            Logging.info("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault()));
    114114            connection.setFixedLengthStreamingMode(requestBody.length);
    115115            connection.setDoOutput(true);
     
    125125                connection.connect();
    126126                final boolean hasReason = reasonForRequest != null && !reasonForRequest.isEmpty();
    127                 Main.info("{0} {1}{2} -> {3}{4}",
     127                Logging.info("{0} {1}{2} -> {3}{4}",
    128128                        requestMethod, url, hasReason ? (" (" + reasonForRequest + ')') : "",
    129129                        connection.getResponseCode(),
     
    132132                                : ""
    133133                );
    134                 if (Main.isDebugEnabled()) {
    135                     Main.debug("RESPONSE: " + connection.getHeaderFields());
     134                if (Logging.isDebugEnabled()) {
     135                    Logging.debug("RESPONSE: {0}", connection.getHeaderFields());
    136136                }
    137137                if (DefaultAuthenticator.getInstance().isEnabled() && connection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
     
    139139                }
    140140            } catch (IOException e) {
    141                 Main.info("{0} {1} -> !!!", requestMethod, url);
    142                 Main.warn(e);
     141                Logging.info("{0} {1} -> !!!", requestMethod, url);
     142                Logging.warn(e);
    143143                //noinspection ThrowableResultOfMethodCallIgnored
    144144                Main.addNetworkError(url, Utils.getRootCause(e));
     
    154154                    url = new URL(url, redirectLocation);
    155155                    maxRedirects--;
    156                     Main.info(tr("Download redirected to ''{0}''", redirectLocation));
     156                    Logging.info(tr("Download redirected to ''{0}''", redirectLocation));
    157157                    return connect();
    158158                } else if (maxRedirects == 0) {
     
    210210                    String content = this.fetchContent();
    211211                    if (content.isEmpty()) {
    212                         Main.debug("Server did not return any body");
     212                        Logging.debug("Server did not return any body");
    213213                    } else {
    214                         Main.debug("Response body: ");
    215                         Main.debug(this.fetchContent());
     214                        Logging.debug("Response body: ");
     215                        Logging.debug(this.fetchContent());
    216216                    }
    217217                } else {
    218                     Main.debug("Server returned content: {0} of length: {1}. Not printing.", contentType, this.getContentLength());
     218                    Logging.debug("Server returned content: {0} of length: {1}. Not printing.", contentType, this.getContentLength());
    219219                }
    220220            }
     
    283283                in = connection.getInputStream();
    284284            } catch (IOException ioe) {
    285                 Main.debug(ioe);
     285                Logging.debug(ioe);
    286286                in = Optional.ofNullable(connection.getErrorStream()).orElseGet(() -> new ByteArrayInputStream(new byte[]{}));
    287287            }
     
    291291            if (uncompress) {
    292292                final String contentType = getContentType();
    293                 Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
     293                Logging.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
    294294                compression = Compression.forContentType(contentType);
    295295            }
     
    299299                        contentDisposition != null ? contentDisposition : "");
    300300                if (matcher.find()) {
    301                     Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
     301                    Logging.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
    302302                    compression = Compression.byExtension(matcher.group(1));
    303303                }
     
    661661                Thread.sleep(100);
    662662            } catch (InterruptedException ex) {
    663                 Main.warn("InterruptedException in " + HttpClient.class + " during cancel");
     663                Logging.warn("InterruptedException in " + HttpClient.class + " during cancel");
    664664                Thread.currentThread().interrupt();
    665665            }
Note: See TracChangeset for help on using the changeset viewer.