Changeset 35019 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2019-05-30T16:00:51+02:00 (6 years ago)
Author:
donvip
Message:

see #josm17744 - use proper logger

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java

    r35016 r35019  
    1212import java.util.Objects;
    1313import java.util.TreeMap;
     14import java.util.logging.Level;
    1415import java.util.logging.Logger;
    1516
     
    109110    public static Logger getLogger(String name) {
    110111        return loggingAdapter.getLogger(name);
     112    }
     113
     114    public static Logger getLogger(Class<?> klass) {
     115        return loggingAdapter.getLogger(klass.getSimpleName());
    111116    }
    112117
     
    155160                }
    156161            } else {
    157                 System.err.println(tr("Opening link not supported on current platform (''{0}'')", url));
     162                getLogger(FeatureAdapter.class).log(Level.SEVERE, tr("Opening link not supported on current platform (''{0}'')", url));
    158163            }
    159164        }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r35018 r35019  
    1515import java.util.concurrent.ThreadPoolExecutor;
    1616import java.util.logging.Level;
     17import java.util.logging.Logger;
    1718
    1819import org.openstreetmap.gui.jmapviewer.interfaces.TileJob;
     
    2627 */
    2728public class OsmTileLoader implements TileLoader {
     29
     30    private static final Logger LOG = FeatureAdapter.getLogger(OsmTileLoader.class);
     31
    2832    /** Setting key for number of threads */
    2933    public static final String THREADS_SETTING = "jmapviewer.osm-tile-loader.threads";
     
    3438            nThreads = FeatureAdapter.getIntSetting(THREADS_SETTING, DEFAULT_THREADS_NUMBER);
    3539        } catch (Exception e) {
    36             FeatureAdapter.getLogger(OsmTileLoader.class.getName()).log(Level.SEVERE, e.getMessage(), e);
    37         }
    38     }
     40            LOG.log(Level.SEVERE, e.getMessage(), e);
     41        }
     42    }
     43
    3944    private static final ThreadPoolExecutor jobDispatcher = (ThreadPoolExecutor) Executors.newFixedThreadPool(nThreads);
    4045
     
    8186                if (input == null) {
    8287                    try {
    83                         System.err.println("Failed loading " + tile.getUrl() +": "
     88                        LOG.log(Level.SEVERE, "Failed loading " + tile.getUrl() +": "
    8489                                +e.getClass() + ": " + e.getMessage());
    8590                    } catch (IOException ioe) {
    86                         ioe.printStackTrace();
     91                        LOG.log(Level.SEVERE, ioe.getMessage(), ioe);
    8792                    }
    8893                }
     
    115120    protected TileLoaderListener listener;
    116121
     122    /**
     123     * Constructs a new {@code OsmTileLoader}.
     124     * @param listener tile loader listener
     125     */
    117126    public OsmTileLoader(TileLoaderListener listener) {
    118127        this(listener, null);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r35017 r35019  
    1515import java.util.concurrent.TimeUnit;
    1616import java.util.concurrent.TimeoutException;
     17import java.util.logging.Level;
     18import java.util.logging.Logger;
    1719import java.util.regex.Pattern;
    1820
     
    4345public class BingAerialTileSource extends TMSTileSource {
    4446
     47    private static final Logger LOG = FeatureAdapter.getLogger(BingAerialTileSource.class);
     48
    4549    /** Setting key for Bing metadata API URL. Must contain {@link #API_KEY_PLACEHOLDER} */
    4650    public static final String METADATA_API_SETTING = "jmapviewer.bing.metadata-api-url";
     
    5559    /** Original Bing API key created by Potlatch2 developers in 2010 */
    5660    private static final String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
     61   
    5762    private static volatile Future<List<Attribution>> attributions; // volatile is required for getAttribution(), see below.
    5863    private static String imageUrlTemplate;
     
    171176
    172177            return attributionsList;
    173         } catch (SAXException e) {
    174             System.err.println("Could not parse Bing aerials attribution metadata.");
    175             e.printStackTrace();
    176         } catch (ParserConfigurationException | XPathExpressionException | NumberFormatException e) {
    177             e.printStackTrace();
     178        } catch (SAXException | ParserConfigurationException | XPathExpressionException | NumberFormatException e) {
     179            LOG.log(Level.SEVERE, "Could not parse Bing aerials attribution metadata.", e);
    178180        }
    179181        return null;
     
    220222            }
    221223        } catch (IOException e) {
    222             System.err.println("Error while retrieving Bing logo: "+e.getMessage());
     224            LOG.log(Level.SEVERE, "Error while retrieving Bing logo: "+e.getMessage());
    223225        }
    224226        return null;
     
    253255                        return r;
    254256                    } catch (IOException ex) {
    255                         System.err.println("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
     257                        LOG.log(Level.SEVERE, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
    256258                        Thread.sleep(TimeUnit.SECONDS.toMillis(waitTimeSec));
    257259                        waitTimeSec *= 2;
     
    276278            return attributions.get(0, TimeUnit.MILLISECONDS);
    277279        } catch (TimeoutException ex) {
    278             System.err.println("Bing: attribution data is not yet loaded.");
     280            LOG.log(Level.WARNING, "Bing: attribution data is not yet loaded.");
    279281        } catch (ExecutionException ex) {
    280282            throw new RuntimeException(ex.getCause());
    281283        } catch (InterruptedException ign) {
    282             System.err.println("InterruptedException: " + ign.getMessage());
     284            LOG.log(Level.SEVERE, "InterruptedException: " + ign.getMessage());
    283285        }
    284286        return null;
Note: See TracChangeset for help on using the changeset viewer.