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/ImageProvider.java

    r12524 r12620  
    642642            } else {
    643643                if (!suppressWarnings) {
    644                     Main.error(tr("Failed to locate image ''{0}''", name));
     644                    Logging.error(tr("Failed to locate image ''{0}''", name));
    645645                }
    646646                return null;
     
    917917                    img = read(Utils.fileToURL(cf.getFile()), false, false);
    918918                } catch (IOException e) {
    919                     Main.warn(e, "IOException while reading HTTP image:");
     919                    Logging.log(Logging.LEVEL_WARN, "IOException while reading HTTP image:", e);
    920920                }
    921921                return img == null ? null : new ImageResource(img);
     
    924924            }
    925925        } catch (IOException e) {
    926             Main.debug(e);
     926            Logging.debug(e);
    927927            return null;
    928928        }
     
    947947                    bytes = Utils.decodeUrl(data).getBytes(StandardCharsets.UTF_8);
    948948                } 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);
    950950                    return null;
    951951                }
     
    960960                }
    961961                if (svg == null) {
    962                     Main.warn("Unable to process svg: "+s);
     962                    Logging.warn("Unable to process svg: "+s);
    963963                    return null;
    964964                }
     
    974974                    return img == null ? null : new ImageResource(img);
    975975                } catch (IOException e) {
    976                     Main.warn(e, "IOException while reading image:");
     976                    Logging.log(Logging.LEVEL_WARN, "IOException while reading image:", e);
    977977                }
    978978            }
     
    10591059                            img = read(new ByteArrayInputStream(buf), false, false);
    10601060                        } catch (IOException e) {
    1061                             Main.warn(e);
     1061                            Logging.warn(e);
    10621062                        }
    10631063                        return img == null ? null : new ImageResource(img);
     
    10681068            }
    10691069        } 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);
    10711071        }
    10721072        return null;
     
    10961096                // hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/dc4322602480/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656
    10971097                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);
    11001100                }
    11011101            } catch (IOException e) {
    1102                 Main.warn(e);
     1102                Logging.warn(e);
    11031103            }
    11041104            return img == null ? null : new ImageResource(img);
     
    11391139                        return u;
    11401140                } catch (SecurityException e) {
    1141                     Main.warn(e, tr(
     1141                    Logging.log(Logging.LEVEL_WARN, tr(
    11421142                            "Failed to access directory ''{0}'' for security reasons. Exception was: {1}",
    1143                             name, e.toString()));
     1143                            name, e.toString()), e);
    11441144                }
    11451145
     
    11541154                    return u;
    11551155            } catch (SecurityException e) {
    1156                 Main.warn(e, tr(
     1156                Logging.log(Logging.LEVEL_WARN, tr(
    11571157                        "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e
    1158                         .toString()));
     1158                        .toString()), e);
    11591159            }
    11601160        }
     
    12261226            }
    12271227        } catch (SAXReturnException e) {
    1228             Main.trace(e);
     1228            Logging.trace(e);
    12291229            return e.getResult();
    12301230        } catch (IOException | SAXException | ParserConfigurationException e) {
    1231             Main.warn("Parsing " + base + fn + " failed:\n" + e);
     1231            Logging.warn("Parsing " + base + fn + " failed:\n" + e);
    12321232            return null;
    12331233        }
    1234         Main.warn("Parsing " + base + fn + " failed: Unexpected content.");
     1234        Logging.warn("Parsing " + base + fn + " failed: Unexpected content.");
    12351235        return null;
    12361236    }
     
    12511251        }
    12521252        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);
    12561254            return null;
    12571255        }
     
    14651463     */
    14661464    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);
    14691467        }
    14701468        float sourceWidth = svg.getWidth();
     
    15041502            }
    15051503        } catch (SVGException ex) {
    1506             Main.error(ex, "Unable to load svg:");
     1504            Logging.log(Logging.LEVEL_ERROR, "Unable to load svg:", ex);
    15071505            return null;
    15081506        }
     
    17241722                    bi = new BufferedImage(bi.getColorModel(), bi.getRaster(), bi.isAlphaPremultiplied(), properties);
    17251723                    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);
    17291725                        bi = makeImageTransparent(bi, color);
    17301726                    }
     
    17341730            // On Windows, ComponentColorModel.getRGBComponent can fail with "UnsatisfiedLinkError: no awt in java.library.path", see #13973
    17351731            // Then it can leads to "NoClassDefFoundError: Could not initialize class sun.awt.image.ShortInterleavedRaster", see #15079
    1736             Main.error(e);
     1732            Logging.error(e);
    17371733        } finally {
    17381734            reader.dispose();
     
    17811777                                                return new Color(r, g, b);
    17821778                                            } 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);
    17841780                                            }
    17851781                                        }
     
    17941790        } catch (IIOException | NumberFormatException e) {
    17951791            // JAI doesn't like some JPEG files with error "Inconsistent metadata read from stream" (see #10267)
    1796             Main.warn(e);
     1792            Logging.warn(e);
    17971793        }
    17981794        return null;
     
    18071803            return new Color(rgb[0], rgb[1], rgb[2]);
    18081804        } catch (IllegalArgumentException e) {
    1809             Main.error(e);
     1805            Logging.error(e);
    18101806            return null;
    18111807        }
Note: See TracChangeset for help on using the changeset viewer.