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

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r12542 r12620  
    5555import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    5656import org.openstreetmap.josm.tools.ListenerList;
     57import org.openstreetmap.josm.tools.Logging;
    5758import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    5859
     
    10101011        OsmPrimitive result = getPrimitiveById(primitiveId);
    10111012        if (result == null && primitiveId != null) {
    1012             Main.warn(tr("JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this "
     1013            Logging.warn(tr("JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this "
    10131014                    + "at {2}. This is not a critical error, it should be safe to continue in your work.",
    10141015                    primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Main.getJOSMWebsite()));
    1015             Main.error(new Exception());
     1016            Logging.error(new Exception());
    10161017        }
    10171018
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r11746 r12620  
    88import java.io.Writer;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.tools.JosmRuntimeException;
     11import org.openstreetmap.josm.tools.Logging;
    1212import org.openstreetmap.josm.tools.Utils;
    1313
     
    186186
    187187    private void printElapsedTime(long startTime) {
    188         if (Main.isDebugEnabled()) {
     188        if (Logging.isDebugEnabled()) {
    189189            StackTraceElement item = Thread.currentThread().getStackTrace()[2];
    190190            String operation = getClass().getSimpleName() + '.' + item.getMethodName();
    191191            long elapsedTime = System.currentTimeMillis() - startTime;
    192             Main.debug(tr("Test ''{0}'' completed in {1}",
     192            Logging.debug(tr("Test ''{0}'' completed in {1}",
    193193                    operation, Utils.getDurationString(elapsedTime)));
    194194        }
     
    216216            writer.println("Exception during dataset integrity test:");
    217217            e.printStackTrace(writer);
    218             Main.warn(e);
     218            Logging.warn(e);
    219219        }
    220220    }
  • trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java

    r12414 r12620  
    2121import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2222import org.openstreetmap.josm.gui.widgets.OSDLabel;
     23import org.openstreetmap.josm.tools.Logging;
    2324import org.openstreetmap.josm.tools.Utils;
    2425
     
    5152                filterMatcher.add(filter);
    5253            } catch (ParseError e) {
    53                 Main.error(e);
     54                Logging.error(e);
    5455                JOptionPane.showMessageDialog(
    5556                        Main.parent,
  • trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java

    r11119 r12620  
    2323import java.util.stream.Collectors;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.tools.CheckParameterUtil;
    2726import org.openstreetmap.josm.tools.Geometry;
    2827import org.openstreetmap.josm.tools.Geometry.PolygonIntersection;
     28import org.openstreetmap.josm.tools.Logging;
    2929import org.openstreetmap.josm.tools.MultiMap;
    3030import org.openstreetmap.josm.tools.Pair;
     
    203203            return makeFromPolygons(joinedWays);
    204204        } catch (JoinedPolygonCreationException ex) {
    205             Main.debug(ex);
     205            Logging.debug(ex);
    206206            return ex.getMessage();
    207207        }
  • trunk/src/org/openstreetmap/josm/data/osm/NoteData.java

    r12540 r12620  
    1717import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    1818import org.openstreetmap.josm.tools.ListenerList;
     19import org.openstreetmap.josm.tools.Logging;
    1920
    2021/**
     
    137138                } else {
    138139                    // TODO merge comments?
    139                     Main.info("Keeping existing note id={0} with uncommitted changes", String.valueOf(newNote.getId()));
     140                    Logging.info("Keeping existing note id={0} with uncommitted changes", String.valueOf(newNote.getId()));
    140141                }
    141142            }
     
    162163        NoteComment comment = new NoteComment(new Date(), getCurrentUser(), text, NoteComment.Action.OPENED, true);
    163164        note.addComment(comment);
    164         if (Main.isDebugEnabled()) {
    165             Main.debug("Created note {0} with comment: {1}", note.getId(), text);
     165        if (Logging.isDebugEnabled()) {
     166            Logging.debug("Created note {0} with comment: {1}", note.getId(), text);
    166167        }
    167168        noteList.add(note);
     
    181182            throw new IllegalStateException("Cannot add a comment to a closed note");
    182183        }
    183         if (Main.isDebugEnabled()) {
    184             Main.debug("Adding comment to note {0}: {1}", note.getId(), text);
     184        if (Logging.isDebugEnabled()) {
     185            Logging.debug("Adding comment to note {0}: {1}", note.getId(), text);
    185186        }
    186187        NoteComment comment = new NoteComment(new Date(), getCurrentUser(), text, NoteComment.Action.COMMENTED, true);
     
    201202            throw new IllegalStateException("Cannot close a note that isn't open");
    202203        }
    203         if (Main.isDebugEnabled()) {
    204             Main.debug("closing note {0} with comment: {1}", note.getId(), text);
     204        if (Logging.isDebugEnabled()) {
     205            Logging.debug("closing note {0} with comment: {1}", note.getId(), text);
    205206        }
    206207        NoteComment comment = new NoteComment(new Date(), getCurrentUser(), text, NoteComment.Action.CLOSED, true);
     
    223224            throw new IllegalStateException("Cannot reopen a note that isn't closed");
    224225        }
    225         if (Main.isDebugEnabled()) {
    226             Main.debug("reopening note {0} with comment: {1}", note.getId(), text);
    227         }
     226        Logging.debug("reopening note {0} with comment: {1}", note.getId(), text);
    228227        NoteComment comment = new NoteComment(new Date(), getCurrentUser(), text, NoteComment.Action.REOPENED, true);
    229228        note.addComment(comment);
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r12190 r12620  
    2727import org.openstreetmap.josm.gui.mappaint.StyleCache;
    2828import org.openstreetmap.josm.tools.CheckParameterUtil;
     29import org.openstreetmap.josm.tools.Logging;
    2930import org.openstreetmap.josm.tools.Utils;
    3031import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
     
    761762            return SearchCompiler.compile(Main.pref.get(prefName, defaultValue));
    762763        } catch (ParseError e) {
    763             Main.error(e, "Unable to compile pattern for " + prefName + ", trying default pattern:");
     764            Logging.log(Logging.LEVEL_ERROR, "Unable to compile pattern for " + prefName + ", trying default pattern:", e);
    764765        }
    765766
  • trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java

    r12537 r12620  
    1010import java.util.NoSuchElementException;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.LatLon;
    1413import org.openstreetmap.josm.data.coor.QuadTiling;
     14import org.openstreetmap.josm.tools.Logging;
    1515
    1616/**
     
    598598        if (searchCache == null) {
    599599            searchCache = root;
    600             Main.info("bbox: " + searchBbox + " is out of the world");
     600            Logging.info("bbox: " + searchBbox + " is out of the world");
    601601        }
    602602
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r12549 r12620  
    2222import java.util.stream.Stream;
    2323
    24 import org.openstreetmap.josm.Main;
     24import org.openstreetmap.josm.tools.Logging;
    2525import org.openstreetmap.josm.tools.Utils;
    2626
     
    725725                result += Integer.parseInt(value);
    726726            } catch (NumberFormatException e) {
    727                 Main.trace(e);
     727                Logging.trace(e);
    728728            }
    729729        }
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java

    r11878 r12620  
    1313import java.util.Objects;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.osm.Changeset;
    1716import org.openstreetmap.josm.data.osm.Node;
     
    2625import org.openstreetmap.josm.data.osm.Way;
    2726import org.openstreetmap.josm.tools.CheckParameterUtil;
     27import org.openstreetmap.josm.tools.Logging;
    2828import org.openstreetmap.josm.tools.date.DateUtils;
    2929
     
    354354            data.setVisible(visible);
    355355        } catch (IllegalStateException e) {
    356             Main.error(e, "Cannot change visibility for "+data+':');
     356            Logging.log(Logging.LEVEL_ERROR, "Cannot change visibility for "+data+':', e);
    357357        }
    358358        data.setTimestamp(timestamp);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java

    r11992 r12620  
    2020import org.openstreetmap.josm.gui.NavigatableComponent;
    2121import org.openstreetmap.josm.tools.CheckParameterUtil;
     22import org.openstreetmap.josm.tools.Logging;
    2223
    2324/**
     
    157158            // On read, it would first check, if the way still has firstIdx+2 nodes, then check if the corresponding way nodes are still
    158159            // the same and report changes in a more controlled manner.
    159             Main.trace(e);
     160            Logging.trace(e);
    160161        }
    161162    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java

    r12279 r12620  
    1717import org.openstreetmap.josm.plugins.PluginHandler;
    1818import org.openstreetmap.josm.tools.CheckParameterUtil;
     19import org.openstreetmap.josm.tools.Logging;
    1920
    2021/**
     
    138139                return Class.forName(className, true, cl);
    139140            } catch (final NoClassDefFoundError | ClassNotFoundException e) {
    140                 Main.trace(e);
     141                Logging.trace(e);
    141142            }
    142143        }
    143         Main.error(tr("Failed to load map renderer class ''{0}''. The class wasn''t found.", className));
     144        Logging.error(tr("Failed to load map renderer class ''{0}''. The class wasn''t found.", className));
    144145        return null;
    145146    }
     
    161162        Class<?> c = loadRendererClass(rendererClassName);
    162163        if (c == null) {
    163             Main.error(tr("Can''t activate map renderer class ''{0}'', because the class wasn''t found.", rendererClassName));
    164             Main.error(tr("Activating the standard map renderer instead."));
     164            Logging.error(tr("Can''t activate map renderer class ''{0}'', because the class wasn''t found.", rendererClassName));
     165            Logging.error(tr("Activating the standard map renderer instead."));
    165166            activateDefault();
    166167        } else if (!AbstractMapRenderer.class.isAssignableFrom(c)) {
    167             Main.error(tr("Can''t activate map renderer class ''{0}'', because it isn''t a subclass of ''{1}''.",
     168            Logging.error(tr("Can''t activate map renderer class ''{0}'', because it isn''t a subclass of ''{1}''.",
    168169                    rendererClassName, AbstractMapRenderer.class.getName()));
    169             Main.error(tr("Activating the standard map renderer instead."));
     170            Logging.error(tr("Activating the standard map renderer instead."));
    170171            activateDefault();
    171172        } else {
    172173            Class<? extends AbstractMapRenderer> renderer = c.asSubclass(AbstractMapRenderer.class);
    173174            if (!isRegistered(renderer)) {
    174                 Main.error(tr("Can''t activate map renderer class ''{0}'', because it isn''t registered as map renderer.", rendererClassName));
    175                 Main.error(tr("Activating the standard map renderer instead."));
     175                Logging.error(tr("Can''t activate map renderer class ''{0}'', because it isn''t registered as map renderer.",
     176                        rendererClassName));
     177                Logging.error(tr("Activating the standard map renderer instead."));
    176178                activateDefault();
    177179            } else {
     
    306308            return AbstractMapRenderer.class.cast(c.newInstance(g, viewport, isInactiveMode));
    307309        } catch (InvocationTargetException e) {
    308             Main.debug(e);
     310            Logging.debug(e);
    309311            throw new MapRendererFactoryException(e.getCause());
    310312        } catch (ReflectiveOperationException | IllegalArgumentException e) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/RenderBenchmarkCollector.java

    r11726 r12620  
    99import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord;
    1010import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
     11import org.openstreetmap.josm.tools.Logging;
    1112import org.openstreetmap.josm.tools.Utils;
    1213
     
    147148     */
    148149    public static Supplier<RenderBenchmarkCollector> defaultBenchmarkSupplier() {
    149         return () -> Main.isTraceEnabled() || Main.pref.getBoolean("mappaint.render.benchmark", false)
     150        return () -> Logging.isTraceEnabled() || Main.pref.getBoolean("mappaint.render.benchmark", false)
    150151                ? new LoggingBenchmark() : new RenderBenchmarkCollector();
    151152    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r12539 r12620  
    241241            gv.setGlyphTransform(0, AffineTransform.getTranslateInstance(1000, 1000));
    242242            Shape shape = gv.getGlyphOutline(0);
    243             if (Main.isTraceEnabled()) {
    244                 Main.trace("#10446: shape: "+shape.getBounds());
     243            if (Logging.isTraceEnabled()) {
     244                Logging.trace("#10446: shape: {0}", shape.getBounds());
    245245            }
    246246            // x is about 1000 on normal stystems and about 2000 when the bug occurs
     
    11291129                                (p1, p2) -> p1.append(p2, false)),
    11301130                        osm.isDisabled(), text);
    1131             } else if (Main.isTraceEnabled()) {
    1132                 Main.trace("Couldn't find a correct label placement for " + osm + " / " + name);
     1131            } else {
     1132                Logging.trace("Couldn't find a correct label placement for {0} / {1}", osm, name);
    11331133            }
    11341134        });
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r12189 r12620  
    3030import org.openstreetmap.josm.tools.Geometry;
    3131import org.openstreetmap.josm.tools.Geometry.AreaAndPerimeter;
     32import org.openstreetmap.josm.tools.Logging;
    3233
    3334/**
     
    405406                if (ds == null) {
    406407                    // DataSet still not found. This should not happen, but a warning does no harm
    407                     Main.warn("DataSet not found while resetting nodes in Multipolygon. " +
     408                    Logging.warn("DataSet not found while resetting nodes in Multipolygon. " +
    408409                            "This should not happen, you may report it to JOSM developers.");
    409410                } else if (wayIds.size() == 1) {
Note: See TracChangeset for help on using the changeset viewer.