Changeset 12620 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2017-08-22T22:26:32+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r12382 r12620 55 55 */ 56 56 public static String explainOsmApiInitializationException(OsmApiInitializationException e) { 57 Main.error(e);57 Logging.error(e); 58 58 return tr( 59 59 "<html>Failed to initialize communication with the OSM server {0}.<br>" … … 70 70 */ 71 71 public static String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) { 72 Main.error(e);72 Logging.error(e); 73 73 return tr( 74 74 "<html>Failed to authenticate at the OSM server ''{0}''.<br>" … … 143 143 */ 144 144 public static String explainPreconditionFailed(OsmApiException e) { 145 Main.error(e);145 Logging.error(e); 146 146 Pair<OsmPrimitive, Collection<OsmPrimitive>> conflict = parsePreconditionFailed(e.getErrorHeader()); 147 147 if (conflict != null) { … … 262 262 */ 263 263 public static String explainFailedBasicAuthentication(OsmApiException e) { 264 Main.error(e);264 Logging.error(e); 265 265 return tr("<html>" 266 266 + "Authentication at the OSM server with the username ''{0}'' failed.<br>" … … 279 279 */ 280 280 public static String explainFailedOAuthAuthentication(OsmApiException e) { 281 Main.error(e);281 Logging.error(e); 282 282 return tr("<html>" 283 283 + "Authentication at the OSM server with the OAuth token ''{0}'' failed.<br>" … … 296 296 */ 297 297 public static String explainFailedAuthorisation(OsmApiException e) { 298 Main.error(e);298 Logging.error(e); 299 299 String header = e.getErrorHeader(); 300 300 String body = e.getErrorBody(); … … 334 334 */ 335 335 public static String explainFailedOAuthAuthorisation(OsmApiException e) { 336 Main.error(e);336 Logging.error(e); 337 337 return tr("<html>" 338 338 + "Authorisation at the OSM server with the OAuth token ''{0}'' failed.<br>" … … 353 353 */ 354 354 public static String explainClientTimeout(OsmApiException e) { 355 Main.error(e);355 Logging.error(e); 356 356 return tr("<html>" 357 357 + "Communication with the OSM server ''{0}'' timed out. Please retry later." … … 368 368 */ 369 369 public static String explainGenericOsmApiException(OsmApiException e) { 370 Main.error(e);370 Logging.error(e); 371 371 return tr("<html>" 372 372 + "Communication with the OSM server ''{0}''failed. The server replied<br>" … … 389 389 */ 390 390 public static String explainConflict(OsmApiException e) { 391 Main.error(e);391 Logging.error(e); 392 392 String msg = e.getErrorHeader(); 393 393 if (msg != null) { … … 399 399 closeDate = DateUtils.newOsmApiDateTimeFormat().parse(m.group(2)); 400 400 } catch (ParseException ex) { 401 Main.error(tr("Failed to parse date ''{0}'' replied by server.", m.group(2)));402 Main.error(ex);401 Logging.error(tr("Failed to parse date ''{0}'' replied by server.", m.group(2))); 402 Logging.error(ex); 403 403 } 404 404 if (closeDate == null) { … … 437 437 */ 438 438 public static String explainChangesetClosedException(ChangesetClosedException e) { 439 Main.error(e);439 Logging.error(e); 440 440 return tr( 441 441 "<html>Failed to upload to changeset <strong>{0}</strong><br>" … … 457 457 msg = e.toString(); 458 458 } 459 Main.error(e);459 Logging.error(e); 460 460 return Utils.escapeReservedCharactersHTML(msg); 461 461 } … … 476 476 } catch (MalformedURLException ex) { 477 477 // shouldn't happen 478 Main.trace(ex);478 Logging.trace(ex); 479 479 } 480 480 … … 493 493 */ 494 494 public static String explainNestedSocketException(OsmTransferException e) { 495 Main.error(e);495 Logging.error(e); 496 496 return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>" 497 497 + "Please check your internet connection.", e.getUrl())+"</html>"; … … 508 508 public static String explainNestedIOException(OsmTransferException e) { 509 509 IOException ioe = getNestedException(e, IOException.class); 510 Main.error(e);510 Logging.error(e); 511 511 return tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>" 512 512 + "due to a problem with transferring data.<br>" … … 525 525 public static String explainNestedIllegalDataException(OsmTransferException e) { 526 526 IllegalDataException ide = getNestedException(e, IllegalDataException.class); 527 Main.error(e);527 Logging.error(e); 528 528 return tr("<html>Failed to download data. " 529 529 + "Its format is either unsupported, ill-formed, and/or inconsistent.<br>" … … 541 541 public static String explainOfflineAccessException(OsmTransferException e) { 542 542 OfflineAccessException oae = getNestedException(e, OfflineAccessException.class); 543 Main.error(e);543 Logging.error(e); 544 544 return tr("<html>Failed to download data.<br>" 545 545 + "<br>Details: {0}</html>", oae != null ? oae.getMessage() : "null"); … … 554 554 */ 555 555 public static String explainInternalServerError(OsmTransferException e) { 556 Main.error(e);556 Logging.error(e); 557 557 return tr("<html>The OSM server<br>" + "''{0}''<br>" + "reported an internal server error.<br>" 558 558 + "This is most likely a temporary problem. Please try again later.", e.getUrl())+"</html>"; … … 576 576 message += tr("<br>Error message(untranslated): {0}", errorHeader); 577 577 } 578 Main.error(e);578 Logging.error(e); 579 579 return "<html>" + message + "</html>"; 580 580 } … … 588 588 */ 589 589 public static String explainBandwidthLimitExceeded(OsmApiException e) { 590 Main.error(e);590 Logging.error(e); 591 591 // TODO: Write a proper error message 592 592 return explainGenericOsmApiException(e); … … 605 605 + "it. Please carefully check the server''s address ''{0}'' for typos.", 606 606 getUrlFromException(e)); 607 Main.error(e);607 Logging.error(e); 608 608 return "<html>" + message + "</html>"; 609 609 } … … 624 624 } catch (MalformedURLException ex) { 625 625 // shouldn't happen 626 Main.trace(e);627 } 628 629 Main.error(e);626 Logging.trace(e); 627 } 628 629 Logging.error(e); 630 630 return tr("<html>Failed to open a connection to the remote server<br>" + "''{0}''.<br>" 631 631 + "Host name ''{1}'' could not be resolved. <br>" … … 719 719 */ 720 720 public static String explainException(Exception e) { 721 Main.error(e);721 Logging.error(e); 722 722 if (e instanceof OsmTransferException) { 723 723 return explainOsmTransferException((OsmTransferException) e); … … 732 732 return new URL(e.getAccessedUrl()).getHost(); 733 733 } catch (MalformedURLException e1) { 734 Main.warn(e1);734 Logging.warn(e1); 735 735 } 736 736 } -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r11745 r12620 46 46 return readTime(metadata); 47 47 } catch (JpegProcessingException | IOException e) { 48 Main.error(e);48 Logging.error(e); 49 49 } 50 50 return null; … … 112 112 date.setTime(date.getTime() + (long) (TimeUnit.SECONDS.toMillis(1) * Double.parseDouble("0." + subSeconds))); 113 113 } catch (NumberFormatException e) { 114 Main.warn("Failed parsing sub seconds from [{0}]", subSeconds);115 Main.warn(e);114 Logging.warn("Failed parsing sub seconds from [{0}]", subSeconds); 115 Logging.warn(e); 116 116 } 117 117 } … … 119 119 } 120 120 } catch (UncheckedParseException e) { 121 Main.error(e);121 Logging.error(e); 122 122 } 123 123 return null; … … 146 146 return dir == null ? null : dir.getInteger(ExifIFD0Directory.TAG_ORIENTATION); 147 147 } catch (JpegProcessingException | IOException e) { 148 Main.error(e);148 Logging.error(e); 149 149 } 150 150 return null; … … 163 163 return readLatLon(dirGps); 164 164 } catch (JpegProcessingException | IOException | MetadataException e) { 165 Main.error(e);165 Logging.error(e); 166 166 } 167 167 return null; … … 197 197 return readDirection(dirGps); 198 198 } catch (JpegProcessingException | IOException e) { 199 Main.error(e);199 Logging.error(e); 200 200 } 201 201 return null; … … 255 255 return readSpeed(dirGps); 256 256 } catch (JpegProcessingException | IOException e) { 257 Main.error(e);257 Logging.error(e); 258 258 } 259 259 return null; … … 299 299 return readElevation(dirGps); 300 300 } catch (JpegProcessingException | IOException e) { 301 Main.error(e);301 Logging.error(e); 302 302 } 303 303 return null; -
trunk/src/org/openstreetmap/josm/tools/GeoUrlToBounds.java
r12382 r12620 41 41 lat = Double.parseDouble(m.group("lat")); 42 42 } catch (NumberFormatException e) { 43 Main.warn(tr("URL does not contain valid {0}", tr("latitude")), e);43 Logging.warn(tr("URL does not contain valid {0}", tr("latitude")), e); 44 44 return null; 45 45 } … … 47 47 lon = Double.parseDouble(m.group("lon")); 48 48 } catch (NumberFormatException e) { 49 Main.warn(tr("URL does not contain valid {0}", tr("longitude")), e);49 Logging.warn(tr("URL does not contain valid {0}", tr("longitude")), e); 50 50 return null; 51 51 } … … 53 53 zoom = m.group("zoom") != null ? Integer.parseInt(m.group("zoom")) : 18; 54 54 } catch (NumberFormatException e) { 55 Main.warn(tr("URL does not contain valid {0}", tr("zoom")), e);55 Logging.warn(tr("URL does not contain valid {0}", tr("zoom")), e); 56 56 return null; 57 57 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r12382 r12620 932 932 outerInner = MultipolygonBuilder.joinWays(multiPolygon); 933 933 } catch (MultipolygonBuilder.JoinedPolygonCreationException ex) { 934 Main.trace(ex);935 Main.debug("Invalid multipolygon " + multiPolygon);934 Logging.trace(ex); 935 Logging.debug("Invalid multipolygon " + multiPolygon); 936 936 return false; 937 937 } -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r12590 r12620 111 111 112 112 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())); 114 114 connection.setFixedLengthStreamingMode(requestBody.length); 115 115 connection.setDoOutput(true); … … 125 125 connection.connect(); 126 126 final boolean hasReason = reasonForRequest != null && !reasonForRequest.isEmpty(); 127 Main.info("{0} {1}{2} -> {3}{4}",127 Logging.info("{0} {1}{2} -> {3}{4}", 128 128 requestMethod, url, hasReason ? (" (" + reasonForRequest + ')') : "", 129 129 connection.getResponseCode(), … … 132 132 : "" 133 133 ); 134 if ( Main.isDebugEnabled()) {135 Main.debug("RESPONSE: " +connection.getHeaderFields());134 if (Logging.isDebugEnabled()) { 135 Logging.debug("RESPONSE: {0}", connection.getHeaderFields()); 136 136 } 137 137 if (DefaultAuthenticator.getInstance().isEnabled() && connection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { … … 139 139 } 140 140 } 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); 143 143 //noinspection ThrowableResultOfMethodCallIgnored 144 144 Main.addNetworkError(url, Utils.getRootCause(e)); … … 154 154 url = new URL(url, redirectLocation); 155 155 maxRedirects--; 156 Main.info(tr("Download redirected to ''{0}''", redirectLocation));156 Logging.info(tr("Download redirected to ''{0}''", redirectLocation)); 157 157 return connect(); 158 158 } else if (maxRedirects == 0) { … … 210 210 String content = this.fetchContent(); 211 211 if (content.isEmpty()) { 212 Main.debug("Server did not return any body");212 Logging.debug("Server did not return any body"); 213 213 } else { 214 Main.debug("Response body: ");215 Main.debug(this.fetchContent());214 Logging.debug("Response body: "); 215 Logging.debug(this.fetchContent()); 216 216 } 217 217 } 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()); 219 219 } 220 220 } … … 283 283 in = connection.getInputStream(); 284 284 } catch (IOException ioe) { 285 Main.debug(ioe);285 Logging.debug(ioe); 286 286 in = Optional.ofNullable(connection.getErrorStream()).orElseGet(() -> new ByteArrayInputStream(new byte[]{})); 287 287 } … … 291 291 if (uncompress) { 292 292 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); 294 294 compression = Compression.forContentType(contentType); 295 295 } … … 299 299 contentDisposition != null ? contentDisposition : ""); 300 300 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); 302 302 compression = Compression.byExtension(matcher.group(1)); 303 303 } … … 661 661 Thread.sleep(100); 662 662 } catch (InterruptedException ex) { 663 Main.warn("InterruptedException in " + HttpClient.class + " during cancel");663 Logging.warn("InterruptedException in " + HttpClient.class + " during cancel"); 664 664 Thread.currentThread().interrupt(); 665 665 } -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r12537 r12620 487 487 } catch (IOException e) { 488 488 // Ignore 489 Main.trace(e);489 Logging.trace(e); 490 490 } 491 491 } … … 517 517 } catch (IOException e) { 518 518 // Ignore exception 519 Main.trace(e);519 Logging.trace(e); 520 520 } 521 521 return false; … … 643 643 } 644 644 } catch (IOException e) { 645 Main.trace(e);645 Logging.trace(e); 646 646 return false; 647 647 } … … 670 670 } else { 671 671 if (!"en".equals(l.getLanguage())) { 672 Main.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.",672 Logging.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.", 673 673 LanguageInfo.getDisplayName(l), LanguageInfo.getDisplayName(Locale.getDefault()))); 674 674 } else { -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r12524 r12620 642 642 } else { 643 643 if (!suppressWarnings) { 644 Main.error(tr("Failed to locate image ''{0}''", name));644 Logging.error(tr("Failed to locate image ''{0}''", name)); 645 645 } 646 646 return null; … … 917 917 img = read(Utils.fileToURL(cf.getFile()), false, false); 918 918 } catch (IOException e) { 919 Main.warn(e, "IOException while reading HTTP image:");919 Logging.log(Logging.LEVEL_WARN, "IOException while reading HTTP image:", e); 920 920 } 921 921 return img == null ? null : new ImageResource(img); … … 924 924 } 925 925 } catch (IOException e) { 926 Main.debug(e);926 Logging.debug(e); 927 927 return null; 928 928 } … … 947 947 bytes = Utils.decodeUrl(data).getBytes(StandardCharsets.UTF_8); 948 948 } catch (IllegalArgumentException ex) { 949 Main.warn(ex, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')');949 Logging.log(Logging.LEVEL_WARN, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')', ex); 950 950 return null; 951 951 } … … 960 960 } 961 961 if (svg == null) { 962 Main.warn("Unable to process svg: "+s);962 Logging.warn("Unable to process svg: "+s); 963 963 return null; 964 964 } … … 974 974 return img == null ? null : new ImageResource(img); 975 975 } catch (IOException e) { 976 Main.warn(e, "IOException while reading image:");976 Logging.log(Logging.LEVEL_WARN, "IOException while reading image:", e); 977 977 } 978 978 } … … 1059 1059 img = read(new ByteArrayInputStream(buf), false, false); 1060 1060 } catch (IOException e) { 1061 Main.warn(e);1061 Logging.warn(e); 1062 1062 } 1063 1063 return img == null ? null : new ImageResource(img); … … 1068 1068 } 1069 1069 } catch (IOException e) { 1070 Main.warn(e, tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));1070 Logging.log(Logging.LEVEL_WARN, tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()), e); 1071 1071 } 1072 1072 return null; … … 1096 1096 // hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/dc4322602480/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656 1097 1097 img = read(path, false, true); 1098 if ( Main.isDebugEnabled() && isTransparencyForced(img)) {1099 Main.debug("Transparency has been forced for image "+path.toExternalForm());1098 if (Logging.isDebugEnabled() && isTransparencyForced(img)) { 1099 Logging.debug("Transparency has been forced for image {0}", path); 1100 1100 } 1101 1101 } catch (IOException e) { 1102 Main.warn(e);1102 Logging.warn(e); 1103 1103 } 1104 1104 return img == null ? null : new ImageResource(img); … … 1139 1139 return u; 1140 1140 } catch (SecurityException e) { 1141 Main.warn(e, tr(1141 Logging.log(Logging.LEVEL_WARN, tr( 1142 1142 "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", 1143 name, e.toString()) );1143 name, e.toString()), e); 1144 1144 } 1145 1145 … … 1154 1154 return u; 1155 1155 } catch (SecurityException e) { 1156 Main.warn(e, tr(1156 Logging.log(Logging.LEVEL_WARN, tr( 1157 1157 "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e 1158 .toString()) );1158 .toString()), e); 1159 1159 } 1160 1160 } … … 1226 1226 } 1227 1227 } catch (SAXReturnException e) { 1228 Main.trace(e);1228 Logging.trace(e); 1229 1229 return e.getResult(); 1230 1230 } catch (IOException | SAXException | ParserConfigurationException e) { 1231 Main.warn("Parsing " + base + fn + " failed:\n" + e);1231 Logging.warn("Parsing " + base + fn + " failed:\n" + e); 1232 1232 return null; 1233 1233 } 1234 Main.warn("Parsing " + base + fn + " failed: Unexpected content.");1234 Logging.warn("Parsing " + base + fn + " failed: Unexpected content."); 1235 1235 return null; 1236 1236 } … … 1251 1251 } 1252 1252 if (GraphicsEnvironment.isHeadless()) { 1253 if (Main.isDebugEnabled()) { 1254 Main.debug("Cursors are not available in headless mode. Returning null for '"+name+'\''); 1255 } 1253 Logging.debug("Cursors are not available in headless mode. Returning null for '{0}'", name); 1256 1254 return null; 1257 1255 } … … 1465 1463 */ 1466 1464 public static BufferedImage createImageFromSvg(SVGDiagram svg, Dimension dim) { 1467 if ( Main.isTraceEnabled()) {1468 Main.trace(String.format("createImageFromSvg: %s %s", svg.getXMLBase(), dim));1465 if (Logging.isTraceEnabled()) { 1466 Logging.trace("createImageFromSvg: {0} {1}", svg.getXMLBase(), dim); 1469 1467 } 1470 1468 float sourceWidth = svg.getWidth(); … … 1504 1502 } 1505 1503 } catch (SVGException ex) { 1506 Main.error(ex, "Unable to load svg:");1504 Logging.log(Logging.LEVEL_ERROR, "Unable to load svg:", ex); 1507 1505 return null; 1508 1506 } … … 1724 1722 bi = new BufferedImage(bi.getColorModel(), bi.getRaster(), bi.isAlphaPremultiplied(), properties); 1725 1723 if (enforceTransparency) { 1726 if (Main.isTraceEnabled()) { 1727 Main.trace("Enforcing image transparency of "+stream+" for "+color); 1728 } 1724 Logging.trace("Enforcing image transparency of {0} for {1}", stream, color); 1729 1725 bi = makeImageTransparent(bi, color); 1730 1726 } … … 1734 1730 // On Windows, ComponentColorModel.getRGBComponent can fail with "UnsatisfiedLinkError: no awt in java.library.path", see #13973 1735 1731 // Then it can leads to "NoClassDefFoundError: Could not initialize class sun.awt.image.ShortInterleavedRaster", see #15079 1736 Main.error(e);1732 Logging.error(e); 1737 1733 } finally { 1738 1734 reader.dispose(); … … 1781 1777 return new Color(r, g, b); 1782 1778 } else { 1783 Main.warn("Unable to translate TransparentColor '"+value+"' with color model "+model);1779 Logging.warn("Unable to translate TransparentColor '"+value+"' with color model "+model); 1784 1780 } 1785 1781 } … … 1794 1790 } catch (IIOException | NumberFormatException e) { 1795 1791 // JAI doesn't like some JPEG files with error "Inconsistent metadata read from stream" (see #10267) 1796 Main.warn(e);1792 Logging.warn(e); 1797 1793 } 1798 1794 return null; … … 1807 1803 return new Color(rgb[0], rgb[1], rgb[2]); 1808 1804 } catch (IllegalArgumentException e) { 1809 Main.error(e);1805 Logging.error(e); 1810 1806 return null; 1811 1807 } -
trunk/src/org/openstreetmap/josm/tools/ImageWarp.java
r11972 r12620 63 63 this.stride = stride; 64 64 this.cache = new HashMap<>(); 65 this.consistencyTest = Main.isDebugEnabled();65 this.consistencyTest = Logging.isDebugEnabled(); 66 66 if (consistencyTest) { 67 67 deletedRows = new HashSet<>(); -
trunk/src/org/openstreetmap/josm/tools/ListenerList.java
r11224 r12620 200 200 @Override 201 201 protected void failAdd(T listener) { 202 Main.trace("Previous addition of the listener");202 Logging.trace("Previous addition of the listener"); 203 203 dumpStack(listenersAdded.get(listener)); 204 204 super.failAdd(listener); … … 207 207 @Override 208 208 protected void failRemove(T listener) { 209 Main.trace("Previous removal of the listener");209 Logging.trace("Previous removal of the listener"); 210 210 dumpStack(listenersRemoved.get(listener)); 211 211 super.failRemove(listener); … … 214 214 private static void dumpStack(StackTraceElement ... stackTraceElements) { 215 215 if (stackTraceElements == null) { 216 Main.trace(" - (no trace recorded)");216 Logging.trace(" - (no trace recorded)"); 217 217 } else { 218 218 Stream.of(stackTraceElements).limit(20).forEach( 219 e -> Main.trace(e.getClassName() + "." + e.getMethodName() + " line " + e.getLineNumber()));219 e -> Logging.trace(e.getClassName() + "." + e.getMethodName() + " line " + e.getLineNumber())); 220 220 } 221 221 } … … 242 242 */ 243 243 public static <T> ListenerList<T> create() { 244 if ( Main.isTraceEnabled()) {244 if (Logging.isTraceEnabled()) { 245 245 return new TracingListenerList<>(); 246 246 } else { -
trunk/src/org/openstreetmap/josm/tools/Logging.java
r11624 r12620 113 113 114 114 /** 115 * Prints an error message for the given Throwable if logging is on. 116 * @param t The throwable object causing the error. 117 * @since 12620 118 */ 119 public static void error(Throwable t) { 120 logWithStackTrace(Logging.LEVEL_ERROR, t); 121 } 122 123 /** 115 124 * Prints a warning message if logging is on. 116 125 * @param message The message to print. … … 131 140 132 141 /** 142 * Prints a warning message for the given Throwable if logging is on. 143 * @param t The throwable object causing the error. 144 * @since 12620 145 */ 146 public static void warn(Throwable t) { 147 logWithStackTrace(Logging.LEVEL_WARN, t); 148 } 149 150 /** 133 151 * Prints a info message if logging is on. 134 152 * @param message The message to print. … … 149 167 150 168 /** 169 * Prints a info message for the given Throwable if logging is on. 170 * @param t The throwable object causing the error. 171 * @since 12620 172 */ 173 public static void info(Throwable t) { 174 logWithStackTrace(Logging.LEVEL_INFO, t); 175 } 176 177 /** 151 178 * Prints a debug message if logging is on. 152 179 * @param message The message to print. … … 167 194 168 195 /** 196 * Prints a debug message for the given Throwable if logging is on. 197 * @param t The throwable object causing the error. 198 * @since 12620 199 */ 200 public static void debug(Throwable t) { 201 logWithStackTrace(Logging.LEVEL_DEBUG, t); 202 } 203 204 /** 169 205 * Prints a trace message if logging is on. 170 206 * @param message The message to print. … … 185 221 186 222 /** 187 * Logs a throwable that happened. 223 * Prints a trace message for the given Throwable if logging is on. 224 * @param t The throwable object causing the error. 225 * @since 12620 226 */ 227 public static void trace(Throwable t) { 228 logWithStackTrace(Logging.LEVEL_TRACE, t); 229 } 230 231 /** 232 * Logs a throwable that happened. The stack trace is not added to the log. 188 233 * @param level The level. 189 234 * @param t The throwable that should be logged. 235 * @see #logWithStackTrace(Level, Throwable) 190 236 */ 191 237 public static void log(Level level, Throwable t) { … … 194 240 195 241 /** 196 * Logs a throwable that happened. 242 * Logs a throwable that happened. The stack trace is not added to the log. 197 243 * @param level The level. 198 244 * @param message An additional error message 199 245 * @param t The throwable that caused the message 246 * @see #logWithStackTrace(Level, String, Throwable) 200 247 */ 201 248 public static void log(Level level, String message, Throwable t) { … … 207 254 * @param level The level. 208 255 * @param t The throwable that should be logged. 256 * @see #log(Level, Throwable) 209 257 */ 210 258 public static void logWithStackTrace(Level level, Throwable t) { … … 217 265 * @param message An additional error message 218 266 * @param t The throwable that should be logged. 267 * @see #logWithStackTrace(Level, Throwable) 219 268 */ 220 269 public static void logWithStackTrace(Level level, String message, Throwable t) { … … 231 280 232 281 private static void logPrivate(Level level, Supplier<String> supplier) { 233 // all log methods imme adiately call one of the logPrivate methods.282 // all log methods immediately call one of the logPrivate methods. 234 283 if (LOGGER.isLoggable(level)) { 235 284 StackTraceElement callingMethod = BugReport.getCallingMethod(1, Logging.class.getName(), name -> !"logPrivate".equals(name)); … … 242 291 * 243 292 * For formatting text, you should use the {@link #debug(String, Object...)} message 244 * @param level A l veleconstant. You can e.g. use {@link Logging#LEVEL_ERROR}245 * @return <code>true</code> if debugis enabled.293 * @param level A level constant. You can e.g. use {@link Logging#LEVEL_ERROR} 294 * @return <code>true</code> if log level is enabled. 246 295 */ 247 296 public static boolean isLoggingEnabled(Level level) { 248 297 return LOGGER.isLoggable(level); 298 } 299 300 /** 301 * Determines if debug log level is enabled. 302 * Useful to avoid costly construction of debug messages when not enabled. 303 * @return {@code true} if log level is at least debug, {@code false} otherwise 304 * @since 12620 305 */ 306 public static boolean isDebugEnabled() { 307 return isLoggingEnabled(Logging.LEVEL_DEBUG); 308 } 309 310 /** 311 * Determines if trace log level is enabled. 312 * Useful to avoid costly construction of trace messages when not enabled. 313 * @return {@code true} if log level is at least trace, {@code false} otherwise 314 * @since 12620 315 */ 316 public static boolean isTraceEnabled() { 317 return isLoggingEnabled(Logging.LEVEL_TRACE); 249 318 } 250 319 -
trunk/src/org/openstreetmap/josm/tools/MemoryManager.java
r10717 r12620 52 52 throw new IllegalArgumentException("Factory did not return a content element."); 53 53 } 54 Main.info(MessageFormat.format("Allocate for {0}: {1} MB of memory. Available: {2} MB.",54 Logging.info(MessageFormat.format("Allocate for {0}: {1} MB of memory. Available: {2} MB.", 55 55 name, maxBytes / 1024 / 1024, getAvailableMemory() / 1024 / 1024)); 56 56 MemoryHandle<T> handle = new ManualFreeMemoryHandle<>(name, content, maxBytes); -
trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java
r11156 r12620 41 41 CheckParameterUtil.ensureParameterNotNull(uri, "uri"); 42 42 43 Main.info(tr("Opening URL: {0}", uri));43 Logging.info(tr("Opening URL: {0}", uri)); 44 44 45 45 if (Desktop.isDesktopSupported()) { … … 59 59 // Workaround for KDE (Desktop API is severely flawed) 60 60 // see https://bugs.openjdk.java.net/browse/JDK-6486393 61 Main.warn(e, "Desktop class failed. Platform dependent fall back for open url in browser.");61 Logging.log(Logging.LEVEL_WARN, "Desktop class failed. Platform dependent fall back for open url in browser.", e); 62 62 displayUrlFallback(uri); 63 63 } 64 64 } 65 65 } catch (IOException e) { 66 Main.warn(e);66 Logging.warn(e); 67 67 return e.getMessage(); 68 68 } 69 69 } else { 70 70 try { 71 Main.warn("Desktop class is not supported. Platform dependent fall back for open url in browser.");71 Logging.warn("Desktop class is not supported. Platform dependent fall back for open url in browser."); 72 72 displayUrlFallback(uri); 73 73 } catch (IOException e) { 74 Main.debug(e);74 Logging.debug(e); 75 75 return e.getMessage(); 76 76 } … … 91 91 return displayUrl(new URI(url)); 92 92 } catch (URISyntaxException e) { 93 Main.debug(e);93 Logging.debug(e); 94 94 return e.getMessage(); 95 95 } -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r12382 r12620 42 42 } 43 43 } catch (IllegalArgumentException ex) { 44 Main.error(ex);44 Logging.error(ex); 45 45 } 46 46 Bounds b = parseShortLink(url); … … 82 82 } 83 83 } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException ex) { 84 Main.error(ex, url);84 Logging.log(Logging.LEVEL_ERROR, url, ex); 85 85 } 86 86 return b; … … 102 102 String[] parts = coordPart.split("/"); 103 103 if (parts.length < 3) { 104 Main.warn(tr("URL does not contain {0}/{1}/{2}", tr("zoom"), tr("latitude"), tr("longitude")));104 Logging.warn(tr("URL does not contain {0}/{1}/{2}", tr("zoom"), tr("latitude"), tr("longitude"))); 105 105 return null; 106 106 } … … 109 109 zoom = Integer.parseInt(parts[0]); 110 110 } catch (NumberFormatException e) { 111 Main.warn(tr("URL does not contain valid {0}", tr("zoom")), e);111 Logging.warn(tr("URL does not contain valid {0}", tr("zoom")), e); 112 112 return null; 113 113 } … … 116 116 lat = Double.parseDouble(parts[1]); 117 117 } catch (NumberFormatException e) { 118 Main.warn(tr("URL does not contain valid {0}", tr("latitude")), e);118 Logging.warn(tr("URL does not contain valid {0}", tr("latitude")), e); 119 119 return null; 120 120 } … … 122 122 lon = Double.parseDouble(parts[2]); 123 123 } catch (NumberFormatException e) { 124 Main.warn(tr("URL does not contain valid {0}", tr("longitude")), e);124 Logging.warn(tr("URL does not contain valid {0}", tr("longitude")), e); 125 125 return null; 126 126 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r12320 r12620 281 281 openUrl(url); 282 282 } catch (IOException e) { 283 Main.warn(e);283 Logging.warn(e); 284 284 } 285 285 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r12537 r12620 75 75 } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) { 76 76 // We'll just ignore this for now. The user will still be able to close JOSM by closing all its windows. 77 Main.warn("Failed to register with OSX: " + ex);77 Logging.warn("Failed to register with OSX: " + ex); 78 78 } 79 79 checkExpiredJava(); … … 113 113 return Class.forName("com.apple.eawt."+className); 114 114 } catch (ClassNotFoundException e) { 115 Main.trace(e);115 Logging.trace(e); 116 116 // Java 9 handlers 117 117 return Class.forName("java.awt.desktop."+className); … … 132 132 Window.class, boolean.class).invoke(eawtFullScreenUtilities, window, Boolean.TRUE); 133 133 } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException e) { 134 Main.warn("Failed to register with OSX: " + e);134 Logging.warn("Failed to register with OSX: " + e); 135 135 } 136 136 } … … 139 139 @Override 140 140 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 141 if ( Main.isDebugEnabled()) {142 Main.debug("OSX handler: "+method.getName()+" - "+Arrays.toString(args));141 if (Logging.isDebugEnabled()) { 142 Logging.debug("OSX handler: {0} - {1}", method.getName(), Arrays.toString(args)); 143 143 } 144 144 switch (method.getName()) { … … 156 156 Thread.sleep(25); 157 157 } catch (InterruptedException e) { 158 Main.warn(e);158 Logging.warn(e); 159 159 Thread.currentThread().interrupt(); 160 160 } … … 165 165 } 166 166 } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) { 167 Main.warn("Failed to access open files event: " + ex);167 Logging.warn("Failed to access open files event: " + ex); 168 168 } 169 169 } … … 175 175 args[1].getClass().getDeclaredMethod(closed ? "performQuit" : "cancelQuit").invoke(args[1]); 176 176 } catch (IllegalAccessException e) { 177 Main.debug(e);177 Logging.debug(e); 178 178 // with Java 9, module java.desktop does not export com.apple.eawt, use new Desktop API instead 179 179 Class.forName("java.awt.desktop.QuitResponse").getMethod(closed ? "performQuit" : "cancelQuit").invoke(args[1]); … … 188 188 break; 189 189 default: 190 Main.warn("OSX unsupported method: "+method.getName());190 Logging.warn("OSX unsupported method: "+method.getName()); 191 191 } 192 192 return null; … … 399 399 .append(')'); 400 400 } catch (IOException e) { 401 Main.error(e);401 Logging.error(e); 402 402 } 403 403 return sb.toString(); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r12411 r12620 90 90 return; 91 91 } catch (IOException | URISyntaxException e) { 92 Main.warn(e);92 Logging.warn(e); 93 93 } 94 94 } … … 125 125 } catch (IOException e) { 126 126 // lsb_release is not available on all Linux systems, so don't log at warning level 127 Main.debug(e);127 Logging.debug(e); 128 128 return false; 129 129 } … … 164 164 } 165 165 } catch (IOException e) { 166 Main.warn(e);166 Logging.warn(e); 167 167 } 168 168 return null; … … 241 241 } 242 242 } catch (IOException e) { 243 Main.debug(e);243 Logging.debug(e); 244 244 // Non LSB-compliant Linux system. List of common fallback release files: http://linuxmafia.com/faq/Admin/release-files.html 245 245 for (LinuxReleaseInfo info : new LinuxReleaseInfo[]{ … … 343 343 } catch (IOException e) { 344 344 // Ignore 345 Main.trace(e);345 Logging.trace(e); 346 346 } 347 347 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r12321 r12620 177 177 } 178 178 } catch (NumberFormatException | ReflectiveOperationException e) { 179 Main.error(e);179 Logging.error(e); 180 180 } 181 181 } … … 304 304 sb.append(" (").append(getCurrentBuild()).append(')'); 305 305 } catch (ReflectiveOperationException e) { 306 Main.error(e);306 Logging.error(e); 307 307 } 308 308 return sb.toString(); … … 346 346 insecurePubKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(INSECURE_PUBLIC_KEY)); 347 347 } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { 348 Main.error(e);348 Logging.error(e); 349 349 return; 350 350 } … … 362 362 } catch (InvalidKeyException | NoSuchProviderException | SignatureException e) { 363 363 // If exception this is not a certificate related to JOSM, just trace it 364 Main.trace(alias + " --> " + e.getClass().getName());365 Main.trace(e);364 Logging.trace(alias + " --> " + e.getClass().getName()); 365 Logging.trace(e); 366 366 } 367 367 } … … 385 385 JOptionPane.showMessageDialog(Main.parent, message.toString(), tr("Warning"), JOptionPane.WARNING_MESSAGE); 386 386 for (String alias : insecureCertificates) { 387 Main.warn(tr("Removing insecure certificate from {0} keystore: {1}", WINDOWS_ROOT, alias));387 Logging.warn(tr("Removing insecure certificate from {0} keystore: {1}", WINDOWS_ROOT, alias)); 388 388 try { 389 389 ks.deleteEntry(alias); 390 390 } catch (KeyStoreException e) { 391 Main.error(e, tr("Unable to remove insecure certificate from keystore: {0}", e.getMessage()));391 Logging.log(Logging.LEVEL_ERROR, tr("Unable to remove insecure certificate from keystore: {0}", e.getMessage()), e); 392 392 } 393 393 } … … 404 404 if (alias != null) { 405 405 // JOSM certificate found, return 406 Main.debug(tr("JOSM localhost certificate found in {0} keystore: {1}", WINDOWS_ROOT, alias));406 Logging.debug(tr("JOSM localhost certificate found in {0} keystore: {1}", WINDOWS_ROOT, alias)); 407 407 return false; 408 408 } 409 409 } catch (ArrayIndexOutOfBoundsException e) { 410 410 // catch error of JDK-8172244 as bug seems to not be fixed anytime soon 411 Main.error(e, "JDK-8172244 occured. Abort HTTPS setup");411 Logging.log(Logging.LEVEL_ERROR, "JDK-8172244 occured. Abort HTTPS setup", e); 412 412 return false; 413 413 } … … 425 425 } 426 426 // install it to Windows-ROOT keystore, used by IE, Chrome and Safari, but not by Firefox 427 Main.info(tr("Adding JOSM localhost certificate to {0} keystore", WINDOWS_ROOT));427 Logging.info(tr("Adding JOSM localhost certificate to {0} keystore", WINDOWS_ROOT)); 428 428 ks.setEntry(entryAlias, trustedCert, null); 429 429 return true; … … 508 508 Path templateFile = FileSystems.getDefault().getPath(javaLibPath, templateFileName); 509 509 if (!Files.isReadable(templateFile)) { 510 Main.warn("extended font config - unable to find font config template file {0}", templateFile.toString());510 Logging.warn("extended font config - unable to find font config template file {0}", templateFile.toString()); 511 511 return; 512 512 } … … 532 532 extras.add(entry); 533 533 } else { 534 Main.trace("extended font config - already registered font for charset ''{0}'' - skipping ''{1}''",534 Logging.trace("extended font config - already registered font for charset ''{0}'' - skipping ''{1}''", 535 535 entry.charset, entry.name); 536 536 } 537 537 } else { 538 Main.trace("extended font config - Font ''{0}'' not found on system - skipping", entry.name);538 Logging.trace("extended font config - Font ''{0}'' not found on system - skipping", entry.name); 539 539 } 540 540 } … … 548 548 String prevValue = props.getProperty(key); 549 549 if (prevValue != null && !prevValue.equals(value)) { 550 Main.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value);550 Logging.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value); 551 551 } 552 552 w.append(key + '=' + value + '\n'); … … 561 561 String prevValue = props.getProperty(key); 562 562 if (prevValue != null && !prevValue.equals(value)) { 563 Main.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value);563 Logging.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value); 564 564 } 565 565 w.append(key + '=' + value + '\n'); … … 575 575 Utils.updateSystemProperty("sun.awt.fontconfig", fontconfigFile.toString()); 576 576 } catch (IOException ex) { 577 Main.error(ex);577 Logging.error(ex); 578 578 } 579 579 } … … 603 603 fontsAvail.add(""); // for devanagari 604 604 } catch (IOException ex) { 605 Main.error(ex, false);606 Main.warn("extended font config - failed to load available Fonts");605 Logging.log(Logging.LEVEL_ERROR, ex); 606 Logging.warn("extended font config - failed to load available Fonts"); 607 607 fontsAvail = null; 608 608 } -
trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
r11709 r12620 117 117 } 118 118 } catch (UserCancelException ex) { 119 Main.warn(ex);119 Logging.warn(ex); 120 120 } catch (JosmRuntimeException ex) { 121 121 // Workaround to #10511 / #14185. To remove when #10511 is solved 122 Main.error(ex);122 Logging.error(ex); 123 123 } 124 124 } 125 125 if (optimizedWays.isEmpty()) { 126 126 // Problem: don't optimize 127 Main.warn("Unable to join left-driving countries polygons");127 Logging.warn("Unable to join left-driving countries polygons"); 128 128 optimizedWays.addAll(ways); 129 129 } … … 142 142 if (r.isMultipolygon() && LEFT.equals(r.get(DRIVING_SIDE)) && 143 143 "inner".equals(r.getMembersFor(s).iterator().next().getRole())) { 144 if ( Main.isDebugEnabled()) {145 Main.debug("Skipping " + w.get("name:en") + " because inner part of " +r.get("name:en"));144 if (Logging.isDebugEnabled()) { 145 Logging.debug("Skipping {0} because inner part of {1}", w.get("name:en"), r.get("name:en")); 146 146 } 147 147 return; … … 169 169 return OsmReader.parseDataSet(is, null).getWays(); 170 170 } catch (IllegalDataException | IOException ex) { 171 Main.trace(ex);171 Logging.trace(ex); 172 172 return Collections.emptyList(); 173 173 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r12520 r12620 286 286 public boolean add(Shortcut shortcut) { 287 287 // expensive consistency check only in debug mode 288 if ( Main.isDebugEnabled()288 if (Logging.isDebugEnabled() 289 289 && stream().map(Shortcut::getShortText).anyMatch(shortcut.getShortText()::equals)) { 290 Main.warn(new AssertionError(shortcut.getShortText() + " already added"));290 Logging.warn(new AssertionError(shortcut.getShortText() + " already added")); 291 291 } 292 292 return super.add(shortcut); … … 430 430 } else if (existing.isPresent()) { 431 431 // this always is a logic error in the hook 432 Main.error("CONFLICT WITH SYSTEM KEY " + shortText + ": " + existing.get());432 Logging.error("CONFLICT WITH SYSTEM KEY " + shortText + ": " + existing.get()); 433 433 return null; 434 434 } … … 475 475 int newmodifier = findNewOsxModifier(requestedGroup); 476 476 if (!findShortcut(requestedKey, newmodifier).isPresent()) { 477 Main.info("Reassigning OSX shortcut '" + shortText + "' from Meta to Ctrl because of conflict with " + conflict);477 Logging.info("Reassigning OSX shortcut '" + shortText + "' from Meta to Ctrl because of conflict with " + conflict); 478 478 return reassignShortcut(shortText, longText, requestedKey, conflict, requestedGroup, requestedKey, newmodifier); 479 479 } … … 483 483 int newmodifier = getGroupModifier(m); 484 484 if (!findShortcut(k, newmodifier).isPresent()) { 485 Main.info("Reassigning shortcut '" + shortText + "' from " + modifier + " to " + newmodifier +485 Logging.info("Reassigning shortcut '" + shortText + "' from " + modifier + " to " + newmodifier + 486 486 " because of conflict with " + conflict); 487 487 return reassignShortcut(shortText, longText, requestedKey, conflict, m, k, newmodifier); … … 512 512 int m, int k, int newmodifier) { 513 513 Shortcut newsc = new Shortcut(shortText, longText, requestedKey, m, k, newmodifier, false, false); 514 Main.info(tr("Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.",514 Logging.info(tr("Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.", 515 515 shortText, conflict.getShortText(), newsc.getKeyText())); 516 516 newsc.saveDefault(); -
trunk/src/org/openstreetmap/josm/tools/Territories.java
r12484 r12620 62 62 GeoPropertyIndex<Boolean> gpi = iso3166Cache.get(code); 63 63 if (gpi == null) { 64 Main.warn(tr("Unknown territory id: {0}", code));64 Logging.warn(tr("Unknown territory id: {0}", code)); 65 65 return false; 66 66 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r12618 r12620 405 405 CheckParameterUtil.ensureParameterNotNull(out, "out"); 406 406 if (!out.exists() && !out.mkdirs()) { 407 Main.warn("Unable to create directory "+out.getPath());407 Logging.warn("Unable to create directory "+out.getPath()); 408 408 } 409 409 File[] files = in.listFiles(); … … 477 477 boolean result = file.delete(); 478 478 if (!result) { 479 Main.warn(tr(warnMsg, file.getPath()));479 Logging.warn(tr(warnMsg, file.getPath())); 480 480 } 481 481 return result; … … 503 503 boolean result = dir.mkdirs(); 504 504 if (!result) { 505 Main.warn(tr(warnMsg, dir.getPath()));505 Logging.warn(tr(warnMsg, dir.getPath())); 506 506 } 507 507 return result; … … 518 518 c.close(); 519 519 } catch (IOException e) { 520 Main.warn(e);520 Logging.warn(e); 521 521 } 522 522 } … … 542 542 return f.toURI().toURL(); 543 543 } catch (MalformedURLException ex) { 544 Main.error("Unable to convert filename " + f.getAbsolutePath() + " to URL");544 Logging.error("Unable to convert filename " + f.getAbsolutePath() + " to URL"); 545 545 } 546 546 } … … 763 763 // Positions the stream at the beginning of first entry 764 764 ZipEntry ze = zis.getNextEntry(); 765 if (ze != null && Main.isDebugEnabled()) {766 Main.debug("Zip entry: "+ze.getName());765 if (ze != null && Logging.isDebugEnabled()) { 766 Logging.debug("Zip entry: {0}", ze.getName()); 767 767 } 768 768 return zis; … … 878 878 */ 879 879 public static String execOutput(List<String> command) throws IOException { 880 if ( Main.isDebugEnabled()) {881 Main.debug(join(" ", command));880 if (Logging.isDebugEnabled()) { 881 Logging.debug(join(" ", command)); 882 882 } 883 883 Process p = new ProcessBuilder(command).start(); … … 909 909 File josmTmpDir = new File(tmpDir, "JOSM"); 910 910 if (!josmTmpDir.exists() && !josmTmpDir.mkdirs()) { 911 Main.warn("Unable to create temp directory " + josmTmpDir);911 Logging.warn("Unable to create temp directory " + josmTmpDir); 912 912 } 913 913 return josmTmpDir; … … 1216 1216 return true; 1217 1217 } catch (MalformedURLException e) { 1218 Main.trace(e);1218 Logging.trace(e); 1219 1219 } 1220 1220 } … … 1279 1279 if (value != null) { 1280 1280 String old = System.setProperty(key, value); 1281 if ( Main.isDebugEnabled() && !value.equals(old)) {1281 if (Logging.isDebugEnabled() && !value.equals(old)) { 1282 1282 if (!key.toLowerCase(Locale.ENGLISH).contains("password")) { 1283 Main.debug("System property '" + key + "' set to '" + value + "'. Old value was '" + old + '\'');1283 Logging.debug("System property '" + key + "' set to '" + value + "'. Old value was '" + old + '\''); 1284 1284 } else { 1285 Main.debug("System property '" + key + "' changed.");1285 Logging.debug("System property '" + key + "' changed."); 1286 1286 } 1287 1287 } … … 1318 1318 public static Document parseSafeDOM(InputStream is) throws ParserConfigurationException, IOException, SAXException { 1319 1319 long start = System.currentTimeMillis(); 1320 if (Main.isDebugEnabled()) { 1321 Main.debug("Starting DOM parsing of " + is); 1322 } 1320 Logging.debug("Starting DOM parsing of {0}", is); 1323 1321 Document result = newSafeDOMBuilder().parse(is); 1324 if ( Main.isDebugEnabled()) {1325 Main.debug("DOM parsing done in " +getDurationString(System.currentTimeMillis() - start));1322 if (Logging.isDebugEnabled()) { 1323 Logging.debug("DOM parsing done in {0}", getDurationString(System.currentTimeMillis() - start)); 1326 1324 } 1327 1325 return result; … … 1355 1353 public static void parseSafeSAX(InputSource is, DefaultHandler dh) throws ParserConfigurationException, SAXException, IOException { 1356 1354 long start = System.currentTimeMillis(); 1357 if (Main.isDebugEnabled()) { 1358 Main.debug("Starting SAX parsing of " + is + " using " + dh); 1359 } 1355 Logging.debug("Starting SAX parsing of {0} using {1}", is, dh); 1360 1356 newSafeSAXParser().parse(is, dh); 1361 if ( Main.isDebugEnabled()) {1362 Main.debug("SAX parsing done in " +getDurationString(System.currentTimeMillis() - start));1357 if (Logging.isDebugEnabled()) { 1358 Logging.debug("SAX parsing done in {0}", getDurationString(System.currentTimeMillis() - start)); 1363 1359 } 1364 1360 } … … 1665 1661 } catch (NoSuchFieldException e) { 1666 1662 // Field is gone with Java 9, there's a method instead 1667 Main.trace(e);1663 Logging.trace(e); 1668 1664 value = c.getDeclaredMethod("getProperty", String.class).invoke(null, "JRE_EXPIRATION_DATE"); 1669 1665 } … … 1672 1668 } 1673 1669 } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException | ParseException e) { 1674 Main.debug(e);1670 Logging.debug(e); 1675 1671 } 1676 1672 return null; … … 1688 1684 .connect().fetchContent().split("\n")[0]; 1689 1685 } catch (IOException e) { 1690 Main.error(e);1686 Logging.error(e); 1691 1687 } 1692 1688 return null; -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r12382 r12620 89 89 initFromPreferences(preferenceKey); 90 90 } catch (WindowGeometryException e) { 91 Main.debug(e);91 Logging.debug(e); 92 92 initFromWindowGeometry(defaultGeometry); 93 93 } … … 248 248 return new WindowGeometry(new Point(x, y), new Dimension(w, h)); 249 249 } else { 250 Main.warn(tr("Ignoring malformed geometry: {0}", arg));250 Logging.warn(tr("Ignoring malformed geometry: {0}", arg)); 251 251 } 252 252 } -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r12382 r12620 160 160 } 161 161 } catch (ReflectiveOperationException | IllegalArgumentException e) { 162 Main.error(e); // SAXException does not dump inner exceptions.162 Logging.error(e); // SAXException does not dump inner exceptions. 163 163 throwException(e); 164 164 } … … 206 206 return f; 207 207 } catch (NoSuchFieldException ex) { 208 Main.trace(ex);208 Logging.trace(ex); 209 209 fields.put(s, null); 210 210 return null; … … 254 254 } catch (SAXException e) { 255 255 // Exception very unlikely to happen, so no need to translate this 256 Main.error(e, "Cannot disable 'load-external-dtd' feature:");256 Logging.log(Logging.LEVEL_ERROR, "Cannot disable 'load-external-dtd' feature:", e); 257 257 } 258 258 reader.parse(new InputSource(in)); -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportQueue.java
r11535 r12620 56 56 Logging.logWithStackTrace(Logging.LEVEL_ERROR, "Handled by bug report queue", report.getCause()); 57 57 if (suppressAllMessages || suppressFor.stream().anyMatch(report::isSame)) { 58 Main.info("User requested to skip error " + report);58 Logging.info("User requested to skip error " + report); 59 59 } else if (reportsToDisplay.size() > 100 || reportsToDisplay.stream().filter(report::isSame).count() >= 10) { 60 Main.warn("Too many errors. Dropping " + report);60 Logging.warn("Too many errors. Dropping " + report); 61 61 } else { 62 62 reportsToDisplay.add(report); … … 109 109 private SuppressionMode displayFor(ReportedException e) { 110 110 if (handlers.stream().anyMatch(p -> p.test(e))) { 111 Main.trace("Intercepted by handler.");111 Logging.trace("Intercepted by handler."); 112 112 return SuppressionMode.NONE; 113 113 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportSender.java
r10618 r12620 28 28 import org.openstreetmap.josm.tools.HttpClient; 29 29 import org.openstreetmap.josm.tools.HttpClient.Response; 30 import org.openstreetmap.josm.tools.Logging; 30 31 import org.openstreetmap.josm.tools.OpenBrowser; 31 32 import org.openstreetmap.josm.tools.Utils; … … 64 65 String openBrowserError = OpenBrowser.displayUrl(getJOSMTicketURL() + "?pdata_stored=" + debugTextPasteId); 65 66 if (openBrowserError != null) { 66 Main.warn(openBrowserError);67 Logging.warn(openBrowserError); 67 68 failed(openBrowserError); 68 69 } 69 70 } catch (BugReportSenderException e) { 70 Main.warn(e);71 Logging.warn(e); 71 72 failed(e.getMessage()); 72 73 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/JosmUpdatePanel.java
r11196 r12620 17 17 import org.openstreetmap.josm.tools.GBC; 18 18 import org.openstreetmap.josm.tools.ImageProvider; 19 import org.openstreetmap.josm.tools.Logging; 19 20 import org.openstreetmap.josm.tools.WikiReader; 20 21 … … 63 64 return Integer.parseInt(testedString.trim()); 64 65 } catch (NumberFormatException | IOException e) { 65 Main.warn(e, "Unable to detect latest version of JOSM:");66 Logging.log(Logging.LEVEL_WARN, "Unable to detect latest version of JOSM:", e); 66 67 return -1; 67 68 } … … 98 99 Main.platform.openUrl(Main.getJOSMWebsite()); 99 100 } catch (IOException ex) { 100 Main.warn(ex, "Unable to access JOSM website:");101 Logging.log(Logging.LEVEL_WARN, "Unable to access JOSM website:", ex); 101 102 } 102 103 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java
r11746 r12620 19 19 import java.util.function.Supplier; 20 20 21 import org.openstreetmap.josm. Main;21 import org.openstreetmap.josm.tools.Logging; 22 22 import org.openstreetmap.josm.tools.StreamUtils; 23 23 … … 219 219 } 220 220 } catch (RuntimeException t) { // NOPMD 221 Main.warn(t);221 Logging.warn(t); 222 222 string = "<Error calling toString()>"; 223 223 } -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r12589 r12620 18 18 import javax.xml.datatype.DatatypeFactory; 19 19 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.data.preferences.BooleanProperty; 22 21 import org.openstreetmap.josm.tools.CheckParameterUtil; 22 import org.openstreetmap.josm.tools.Logging; 23 23 import org.openstreetmap.josm.tools.UncheckedParseException; 24 24 … … 51 51 fact = DatatypeFactory.newInstance(); 52 52 } catch (DatatypeConfigurationException e) { 53 Main.error(e);53 Logging.error(e); 54 54 } 55 55 XML_DATE = fact;
Note:
See TracChangeset
for help on using the changeset viewer.