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/validation
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r12542 r12620  
    6161import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    6262import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
     63import org.openstreetmap.josm.tools.Logging;
    6364import org.openstreetmap.josm.tools.Utils;
    6465
     
    143144            allTestsMap.put(testClass.getName(), testClass.getConstructor().newInstance());
    144145        } catch (ReflectiveOperationException e) {
    145             Main.error(e);
     146            Logging.error(e);
    146147        }
    147148    }
     
    189190                    ignoredErrors.addAll(Files.readAllLines(path, StandardCharsets.UTF_8));
    190191                } catch (final FileNotFoundException e) {
    191                     Main.debug(Main.getErrorMessage(e));
     192                    Logging.debug(Logging.getErrorMessage(e));
    192193                } catch (final IOException e) {
    193                     Main.error(e);
     194                    Logging.error(e);
    194195                }
    195196            }
     
    225226            }
    226227        } catch (IOException e) {
    227             Main.error(e);
     228            Logging.error(e);
    228229        }
    229230    }
     
    355356    public static synchronized void initializeTests() {
    356357        if (!testsInitialized) {
    357             Main.debug("Initializing validator tests");
     358            Logging.debug("Initializing validator tests");
    358359            final long startTime = System.currentTimeMillis();
    359360            initializeTests(getTests());
    360361            testsInitialized = true;
    361             if (Main.isDebugEnabled()) {
     362            if (Logging.isDebugEnabled()) {
    362363                final long elapsedTime = System.currentTimeMillis() - startTime;
    363                 Main.debug("Initializing validator tests completed in " + Utils.getDurationString(elapsedTime));
     364                Logging.debug("Initializing validator tests completed in {0}", Utils.getDurationString(elapsedTime));
    364365            }
    365366        }
     
    377378                }
    378379            } catch (Exception e) { // NOPMD
    379                 Main.error(e);
     380                Logging.error(e);
    380381                if (!GraphicsEnvironment.isHeadless()) {
    381382                    JOptionPane.showMessageDialog(Main.parent,
  • trunk/src/org/openstreetmap/josm/data/validation/Severity.java

    r12390 r12620  
    77import java.awt.Color;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.preferences.ColorProperty;
     10import org.openstreetmap.josm.tools.Logging;
    1111
    1212/** The error severity */
     
    4848    public static void getColors() {
    4949        for (Severity c : values()) {
    50             if (Main.isDebugEnabled()) {
    51                 Main.debug(c.toString());
    52             }
     50            Logging.debug("{0}", c);
    5351        }
    5452    }
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r11608 r12620  
    2727import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2828import org.openstreetmap.josm.tools.GBC;
     29import org.openstreetmap.josm.tools.Logging;
    2930import org.openstreetmap.josm.tools.Utils;
    3031
     
    153154        String startMessage = tr("Running test {0}", name);
    154155        this.progressMonitor.beginTask(startMessage);
    155         Main.debug(startMessage);
     156        Logging.debug(startMessage);
    156157        this.errors = new ArrayList<>(30);
    157158        this.startTime = System.currentTimeMillis();
     
    187188            // fix #11567 where elapsedTime is < 0
    188189            long elapsedTime = Math.max(0, System.currentTimeMillis() - startTime);
    189             Main.debug(tr("Test ''{0}'' completed in {1}", getName(), Utils.getDurationString(elapsedTime)));
     190            Logging.debug(tr("Test ''{0}'' completed in {1}", getName(), Utils.getDurationString(elapsedTime)));
    190191        }
    191192    }
  • trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java

    r12466 r12620  
    2121import java.util.Locale;
    2222
    23 import org.openstreetmap.josm.Main;
     23import org.openstreetmap.josm.tools.Logging;
    2424
    2525/**
     
    20522052            }
    20532053        } catch (IllegalArgumentException e) { // input is not valid
    2054             Main.trace(e);
     2054            Logging.trace(e);
    20552055            return input;
    20562056        }
  • trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

    r11893 r12620  
    2929import java.util.regex.Pattern;
    3030
    31 import org.openstreetmap.josm.Main;
     31import org.openstreetmap.josm.tools.Logging;
    3232
    3333/**
     
    450450            }
    451451        } catch (URISyntaxException e) {
    452             Main.trace(e);
     452            Logging.trace(e);
    453453            return false;
    454454        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r12318 r12620  
    2626import org.openstreetmap.josm.data.validation.TestError;
    2727import org.openstreetmap.josm.tools.Geometry;
     28import org.openstreetmap.josm.tools.Logging;
    2829import org.openstreetmap.josm.tools.Pair;
    2930import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    216217                    }
    217218                } else {
    218                     Main.warn("Addresses test skipped chunck "+chunk+" for street part "+streetPart+" because p1 or p2 is null");
     219                    Logging.warn("Addresses test skipped chunck "+chunk+" for street part "+streetPart+" because p1 or p2 is null");
    219220                }
    220221            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java

    r12402 r12620  
    1313import java.util.regex.Pattern;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1716import org.openstreetmap.josm.data.validation.Severity;
     
    1918import org.openstreetmap.josm.data.validation.TestError;
    2019import org.openstreetmap.josm.tools.LanguageInfo;
     20import org.openstreetmap.josm.tools.Logging;
    2121import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2222
     
    207207            }
    208208        } catch (ConditionalParsingException ex) {
    209             Main.debug(ex);
     209            Logging.debug(ex);
    210210            return ex.getMessage();
    211211        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r11913 r12620  
    1111import java.util.Objects;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.data.coor.EastNorth;
    1514import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2322import org.openstreetmap.josm.data.validation.util.ValUtil;
    2423import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     24import org.openstreetmap.josm.tools.Logging;
    2525
    2626/**
     
    268268            final EastNorth en2 = es1.getSecondNode().getEastNorth();
    269269            if (en1 == null || en2 == null) {
    270                 Main.warn("Crossing ways test skipped "+es1);
     270                Logging.warn("Crossing ways test skipped "+es1);
    271271                continue;
    272272            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Lanes.java

    r12461 r12620  
    88import java.util.stream.Collectors;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1211import org.openstreetmap.josm.data.validation.Severity;
    1312import org.openstreetmap.josm.data.validation.Test;
    1413import org.openstreetmap.josm.data.validation.TestError;
     14import org.openstreetmap.josm.tools.Logging;
    1515import org.openstreetmap.josm.tools.Utils;
    1616
     
    6464                }
    6565            } catch (NumberFormatException ignore) {
    66                 Main.debug(ignore.getMessage());
     66                Logging.debug(ignore.getMessage());
    6767            }
    6868        }
     
    8282        }
    8383        } catch (NumberFormatException ignore) {
    84             Main.debug(ignore.getMessage());
     84            Logging.debug(ignore.getMessage());
    8585        }
    8686    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r12410 r12620  
    22package org.openstreetmap.josm.data.validation.tests;
    33
     4import static org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.FixCommand.evaluateObject;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    6465import org.openstreetmap.josm.io.UTFInputStreamReader;
    6566import org.openstreetmap.josm.tools.CheckParameterUtil;
     67import org.openstreetmap.josm.tools.Logging;
    6668import org.openstreetmap.josm.tools.MultiMap;
    6769import org.openstreetmap.josm.tools.Utils;
     
    319321                                check.errors.put(ai, Severity.valueOf(ai.key.substring("throw".length()).toUpperCase(Locale.ENGLISH)));
    320322                            } catch (IllegalArgumentException e) {
    321                                 Main.warn(e, "Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS+'.');
     323                                Logging.log(Logging.LEVEL_WARN,
     324                                        "Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS+'.', e);
    322325                            }
    323326                        } else if ("fixAdd".equals(ai.key)) {
     
    388391                            new GroupedMapCSSRule(map.getValue(), map.getKey())));
    389392                } catch (IllegalDataException e) {
    390                     Main.error("Cannot add MapCss rule: "+e.getMessage());
     393                    Logging.error("Cannot add MapCss rule: "+e.getMessage());
    391394                    source.logError(e);
    392395                }
     
    452455                }
    453456            } catch (IndexOutOfBoundsException ignore) {
    454                 Main.debug(ignore);
     457                Logging.debug(ignore);
    455458            }
    456459            return null;
     
    480483                    m.appendReplacement(sb, String.valueOf(argument).replace("^(", "").replace(")$", ""));
    481484                } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
    482                     Main.error(e, tr("Unable to replace argument {0} in {1}: {2}", argument, sb, e.getMessage()));
     485                    Logging.log(Logging.LEVEL_ERROR, tr("Unable to replace argument {0} in {1}: {2}", argument, sb, e.getMessage()), e);
    483486                }
    484487            }
     
    735738            if (Main.pref.getBoolean("validator.check_assert_local_rules", false) && Utils.isLocalUrl(url)) {
    736739                for (String msg : checkAsserts(result.parseChecks)) {
    737                     Main.warn(msg);
     740                    Logging.warn(msg);
    738741                }
    739742            }
     
    752755            try {
    753756                if (!i.startsWith("resource:")) {
    754                     Main.info(tr("Adding {0} to tag checker", i));
    755                 } else if (Main.isDebugEnabled()) {
    756                     Main.debug(tr("Adding {0} to tag checker", i));
     757                    Logging.info(tr("Adding {0} to tag checker", i));
     758                } else if (Logging.isDebugEnabled()) {
     759                    Logging.debug(tr("Adding {0} to tag checker", i));
    757760                }
    758761                addMapCSS(i);
     
    761764                }
    762765            } catch (IOException | IllegalStateException | IllegalArgumentException ex) {
    763                 Main.warn(tr("Failed to add {0} to tag checker", i));
    764                 Main.warn(ex, false);
     766                Logging.warn(tr("Failed to add {0} to tag checker", i));
     767                Logging.log(Logging.LEVEL_WARN, ex);
    765768            } catch (ParseException ex) {
    766                 Main.warn(tr("Failed to add {0} to tag checker", i));
    767                 Main.warn(ex);
     769                Logging.warn(tr("Failed to add {0} to tag checker", i));
     770                Logging.warn(ex);
    768771            }
    769772        }
     
    780783        final DataSet ds = new DataSet();
    781784        for (final TagCheck check : schecks) {
    782             if (Main.isDebugEnabled()) {
    783                 Main.debug("Check: "+check);
    784             }
     785            Logging.debug("Check: {0}", check);
    785786            for (final Map.Entry<String, Boolean> i : check.assertions.entrySet()) {
    786                 if (Main.isDebugEnabled()) {
    787                     Main.debug("- Assertion: "+i);
    788                 }
     787                Logging.debug("- Assertion: {0}", i);
    789788                final OsmPrimitive p = OsmUtils.createPrimitive(i.getKey());
    790789                // Build minimal ordered list of checks to run to test the assertion
     
    798797                ds.addPrimitive(p);
    799798                final Collection<TestError> pErrors = getErrorsForPrimitive(p, true, checksToRun);
    800                 if (Main.isDebugEnabled()) {
    801                     Main.debug("- Errors: "+pErrors);
    802                 }
     799                Logging.debug("- Errors: {0}", pErrors);
    803800                @SuppressWarnings({"EqualsBetweenInconvertibleTypes", "EqualsIncompatibleType"})
    804801                final boolean isError = pErrors.stream().anyMatch(e -> e.getTester().equals(check.rule));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r11893 r12620  
    1818import java.util.Set;
    1919
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.command.ChangeCommand;
    2221import org.openstreetmap.josm.command.Command;
     
    4140import org.openstreetmap.josm.tools.Geometry;
    4241import org.openstreetmap.josm.tools.Geometry.PolygonIntersection;
     42import org.openstreetmap.josm.tools.Logging;
    4343
    4444/**
     
    591591            final EastNorth en2 = es1.getSecondNode().getEastNorth();
    592592            if (en1 == null || en2 == null) {
    593                 Main.warn("Crossing ways test (MP) skipped " + es1);
     593                Logging.warn("Crossing ways test (MP) skipped " + es1);
    594594                continue;
    595595            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r11889 r12620  
    1515import javax.script.ScriptException;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.command.ChangePropertyCommand;
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2322import org.openstreetmap.josm.io.CachedFile;
    2423import org.openstreetmap.josm.tools.LanguageInfo;
     24import org.openstreetmap.josm.tools.Logging;
    2525
    2626/**
     
    7272            }
    7373        } else {
    74             Main.warn("Unable to initialize OpeningHourTest because no JavaScript engine has been found");
     74            Logging.warn("Unable to initialize OpeningHourTest because no JavaScript engine has been found");
    7575        }
    7676    }
     
    207207                prettifiedValue = (String) ((Invocable) ENGINE).invokeMethod(r, "prettifyValue");
    208208            } catch (ScriptException | NoSuchMethodException e) {
    209                 Main.warn(e);
     209                Logging.warn(e);
    210210            }
    211211            for (final Object i : getList(((Invocable) ENGINE).invokeMethod(r, "getErrors"))) {
     
    219219            }
    220220        } catch (ScriptException | NoSuchMethodException ex) {
    221             Main.error(ex);
     221            Logging.error(ex);
    222222        }
    223223        return errors;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r12390 r12620  
    5151import org.openstreetmap.josm.io.CachedFile;
    5252import org.openstreetmap.josm.tools.GBC;
     53import org.openstreetmap.josm.tools.Logging;
    5354import org.openstreetmap.josm.tools.MultiMap;
    5455import org.openstreetmap.josm.tools.Utils;
     
    205206                            tagcheckerfile = true;
    206207                            if (!DEFAULT_SOURCES.contains(source)) {
    207                                 Main.info(tr("Adding {0} to tag checker", source));
     208                                Logging.info(tr("Adding {0} to tag checker", source));
    208209                            }
    209210                        } else
     
    211212                            ignorefile = true;
    212213                            if (!DEFAULT_SOURCES.contains(source)) {
    213                                 Main.info(tr("Adding {0} to ignore tags", source));
     214                                Logging.info(tr("Adding {0} to ignore tags", source));
    214215                            }
    215216                        }
     
    238239                        default:
    239240                            if (!key.startsWith(";")) {
    240                                 Main.warn("Unsupported TagChecker key: " + key);
     241                                Logging.warn("Unsupported TagChecker key: " + key);
    241242                            }
    242243                        }
     
    249250                                checkerData.add(d);
    250251                            } else {
    251                                 Main.error(tr("Invalid tagchecker line - {0}: {1}", err, line));
     252                                Logging.error(tr("Invalid tagchecker line - {0}: {1}", err, line));
    252253                            }
    253254                        }
     
    257258                        harmonizedKeys.put(harmonizeKey(line.substring(1)), okValue);
    258259                    } else {
    259                         Main.error(tr("Invalid spellcheck line: {0}", line));
     260                        Logging.error(tr("Invalid spellcheck line: {0}", line));
    260261                    }
    261262                    if (isFirstLine) {
    262263                        isFirstLine = false;
    263264                        if (!(tagcheckerfile || ignorefile) && !DEFAULT_SOURCES.contains(source)) {
    264                             Main.info(tr("Adding {0} to spellchecker", source));
     265                            Logging.info(tr("Adding {0} to spellchecker", source));
    265266                        }
    266267                    }
    267268                }
    268269            } catch (IOException e) {
    269                 Main.error(e);
     270                Logging.error(e);
    270271                errorSources.append(source).append('\n');
    271272            }
     
    828829                }
    829830            } catch (IllegalStateException e) {
    830                 Main.error(e);
     831                Logging.error(e);
    831832                description = null;
    832833            }
     
    871872                    data.add(new CheckerElement(exp));
    872873                } catch (IllegalStateException e) {
    873                     Main.trace(e);
     874                    Logging.trace(e);
    874875                    return tr("Illegal expression ''{0}''", exp);
    875876                } catch (PatternSyntaxException e) {
    876                     Main.trace(e);
     877                    Logging.trace(e);
    877878                    return tr("Illegal regular expression ''{0}''", exp);
    878879                }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r11913 r12620  
    3333import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    3434import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     35import org.openstreetmap.josm.tools.Logging;
    3536
    3637/**
     
    318319        public boolean nearby(Node n, double dist) {
    319320            if (w == null) {
    320                 Main.debug("way null");
     321                Logging.debug("way null");
    321322                return false;
    322323            }
Note: See TracChangeset for help on using the changeset viewer.