Ignore:
Timestamp:
2013-09-23T16:47:50+02:00 (11 years ago)
Author:
Don-vip
Message:

Rework console output:

  • new log level "error"
  • Replace nearly all calls to system.out and system.err to Main.(error|warn|info|debug)
  • Remove some unnecessary debug output
  • Some messages are modified (removal of "Info", "Warning", "Error" from the message itself -> notable i18n impact but limited to console error messages not seen by the majority of users, so that's ok)
Location:
trunk/src/org/openstreetmap/josm/tools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r6232 r6248  
    370370                try {
    371371                    closeDate = formatter.parse(m.group(2));
    372                 } catch(ParseException ex) {
    373                     System.err.println(tr("Failed to parse date ''{0}'' replied by server.", m.group(2)));
     372                } catch (ParseException ex) {
     373                    Main.error(tr("Failed to parse date ''{0}'' replied by server.", m.group(2)));
    374374                    ex.printStackTrace();
    375375                }
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r6084 r6248  
    55import java.io.File;
    66import java.io.FileInputStream;
     7import java.io.IOException;
    78import java.io.InputStream;
    8 import java.io.IOException;
    99import java.net.URL;
    1010import java.text.MessageFormat;
     
    1414import java.util.Comparator;
    1515import java.util.HashMap;
     16import java.util.Locale;
    1617import java.util.jar.JarInputStream;
    1718import java.util.zip.ZipEntry;
    18 import java.util.Locale;
    1919
    2020import javax.swing.JColorChooser;
     
    641641            } else {
    642642                if (!l.getLanguage().equals("en")) {
    643                     System.out.println(tr("Unable to find translation for the locale {0}. Reverting to {1}.",
     643                    Main.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.",
    644644                            l.getDisplayName(), Locale.getDefault().getDisplayName()));
    645645                } else {
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r6246 r6248  
    308308            } else {
    309309                if (!suppressWarnings) {
    310                     System.err.println(tr("Failed to locate image ''{0}''", name));
     310                    Main.error(tr("Failed to locate image ''{0}''", name));
    311311                }
    312312                return null;
     
    613613            }
    614614        } catch (Exception e) {
    615             System.err.println(tr("Warning: failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));
     615            Main.warn(tr("Failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));
    616616        } finally {
    617617            Utils.close(zipFile);
     
    671671                        return u;
    672672                } catch (SecurityException e) {
    673                     System.out.println(tr(
    674                             "Warning: failed to access directory ''{0}'' for security reasons. Exception was: {1}",
     673                    Main.warn(tr(
     674                            "Failed to access directory ''{0}'' for security reasons. Exception was: {1}",
    675675                            name, e.toString()));
    676676                }
     
    685685                return u;
    686686        } catch (SecurityException e) {
    687             System.out.println(tr(
    688                     "Warning: failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e
     687            Main.warn(tr(
     688                    "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e
    689689                    .toString()));
    690690        }
     
    736736                @Override
    737737                public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
    738                     System.out.println();
    739738                    if (localName.equalsIgnoreCase("img")) {
    740739                        String val = atts.getValue("src");
     
    759758            return r.getResult();
    760759        } catch (Exception e) {
    761             System.out.println("INFO: parsing " + base + fn + " failed:\n" + e);
     760            Main.warn("Parsing " + base + fn + " failed:\n" + e);
    762761            return null;
    763762        }
    764         System.out.println("INFO: parsing " + base + fn + " failed: Unexpected content.");
     763        Main.warn("Parsing " + base + fn + " failed: Unexpected content.");
    765764        return null;
    766765    }
  • trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java

    r6070 r6248  
    5151                    // Workaround for KDE (Desktop API is severely flawed)
    5252                    // see http://bugs.sun.com/view_bug.do?bug_id=6486393
    53                     System.err.println("Warning: Desktop class failed. Platform dependent fall back for open url in browser.");
     53                    Main.warn("Desktop class failed. Platform dependent fall back for open url in browser.");
    5454                    displayUrlFallback(uri);
    5555                }
     
    6060        } else {
    6161            try {
    62                 System.err.println("Warning: Desktop class is not supported. Platform dependent fall back for open url in browser.");
     62                Main.warn("Desktop class is not supported. Platform dependent fall back for open url in browser.");
    6363                displayUrlFallback(uri);
    6464            } catch (IOException e) {
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r6125 r6248  
    4040            MsetEnabledPreferencesMenu.invoke(Ocom_apple_eawt_Application, new Object[] { Boolean.TRUE });
    4141        } catch (Exception ex) {
    42             // Oops, what now?
    43             // We'll just ignore this for now. The user will still be able to close JOSM
    44             // by closing all its windows.
    45             System.out.println("Failed to register with OSX: " + ex);
     42            // We'll just ignore this for now. The user will still be able to close JOSM by closing all its windows.
     43            Main.warn("Failed to register with OSX: " + ex);
    4644        }
    4745    }
     
    4947    public Object invoke (Object proxy, Method method, Object[] args) throws Throwable {
    5048        Boolean handled = Boolean.TRUE;
    51         //System.out.println("Going to handle method "+method+" (short: "+method.getName()+") with event "+args[0]);
    5249        if (method.getName().equals("handleQuit")) {
    5350            handled = Main.exitJosm(false, 0);
     
    6259                args[0].getClass().getDeclaredMethod("setHandled", new Class[] { boolean.class }).invoke(args[0], new Object[] { handled });
    6360            } catch (Exception ex) {
    64                 System.out.println("Failed to report handled event: " + ex);
     61                Main.warn("Failed to report handled event: " + ex);
    6562            }
    6663        }
     
    6966    @Override
    7067    public void openUrl(String url) throws IOException {
    71         // Ain't that KISS?
    7268        Runtime.getRuntime().exec("open " + url);
    7369    }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r5979 r6248  
    371371        if (potentialShortcut != null) {
    372372            // this always is a logic error in the hook
    373             System.err.println("CONFLICT WITH SYSTEM KEY "+shortText);
     373            Main.error("CONFLICT WITH SYSTEM KEY "+shortText);
    374374            return null;
    375375        }
     
    415415                    if ( findShortcut(k, newmodifier) == null ) {
    416416                        Shortcut newsc = new Shortcut(shortText, longText, requestedKey, m, k, newmodifier, false, false);
    417                         System.out.println(tr("Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.",
     417                        Main.info(tr("Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.",
    418418                            shortText, conflict.getShortText(), newsc.getKeyText()));
    419419                        newsc.saveDefault();
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r6229 r6248  
    2424import javax.xml.validation.ValidatorHandler;
    2525
     26import org.openstreetmap.josm.Main;
    2627import org.openstreetmap.josm.io.MirroredInputStream;
    2728import org.xml.sax.Attributes;
     
    296297            } catch (SAXException e) {
    297298                // Exception very unlikely to happen, so no need to translate this
    298                 System.err.println("Cannot disable 'load-external-dtd' feature: "+e.getMessage());
     299                Main.error("Cannot disable 'load-external-dtd' feature: "+e.getMessage());
    299300            }
    300301            reader.parse(new InputSource(in));
Note: See TracChangeset for help on using the changeset viewer.