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)
File:
1 edited

Legend:

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

    r6235 r6248  
    373373        }
    374374        if (!cacheDirFile.exists() && !cacheDirFile.mkdirs()) {
    375             System.err.println(tr("Warning: Failed to create missing cache directory: {0}", cacheDirFile.getAbsoluteFile()));
     375            Main.warn(tr("Failed to create missing cache directory: {0}", cacheDirFile.getAbsoluteFile()));
    376376            JOptionPane.showMessageDialog(
    377377                    Main.parent,
     
    499499            defaults.put(key, def);
    500500        } else if(def != null && !defaults.get(key).equals(def)) {
    501             System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key));
     501            Main.info("Defaults for " + key + " differ: " + def + " != " + defaults.get(key));
    502502        }
    503503    }
     
    556556                try {
    557557                    save();
    558                 } catch(IOException e){
    559                     System.out.println(tr("Warning: failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     558                } catch (IOException e) {
     559                    Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
    560560                }
    561561                changed = true;
     
    652652        if (prefDir.exists()) {
    653653            if(!prefDir.isDirectory()) {
    654                 System.err.println(tr("Warning: Failed to initialize preferences. Preference directory ''{0}'' is not a directory.", prefDir.getAbsoluteFile()));
     654                Main.warn(tr("Failed to initialize preferences. Preference directory ''{0}'' is not a directory.", prefDir.getAbsoluteFile()));
    655655                JOptionPane.showMessageDialog(
    656656                        Main.parent,
     
    663663        } else {
    664664            if (! prefDir.mkdirs()) {
    665                 System.err.println(tr("Warning: Failed to initialize preferences. Failed to create missing preference directory: {0}", prefDir.getAbsoluteFile()));
     665                Main.warn(tr("Failed to initialize preferences. Failed to create missing preference directory: {0}", prefDir.getAbsoluteFile()));
    666666                JOptionPane.showMessageDialog(
    667667                        Main.parent,
     
    677677        try {
    678678            if (!preferenceFile.exists()) {
    679                 System.out.println(tr("Info: Missing preference file ''{0}''. Creating a default preference file.", preferenceFile.getAbsoluteFile()));
     679                Main.info(tr("Missing preference file ''{0}''. Creating a default preference file.", preferenceFile.getAbsoluteFile()));
    680680                resetToDefault();
    681681                save();
    682682            } else if (reset) {
    683                 System.out.println(tr("Warning: Replacing existing preference file ''{0}'' with default preference file.", preferenceFile.getAbsoluteFile()));
     683                Main.warn(tr("Replacing existing preference file ''{0}'' with default preference file.", preferenceFile.getAbsoluteFile()));
    684684                resetToDefault();
    685685                save();
     
    712712            } catch(IOException e1) {
    713713                e1.printStackTrace();
    714                 System.err.println(tr("Warning: Failed to initialize preferences. Failed to reset preference file to default: {0}", getPreferenceFile()));
     714                Main.warn(tr("Failed to initialize preferences. Failed to reset preference file to default: {0}", getPreferenceFile()));
    715715            }
    716716        }
     
    906906            try {
    907907                save();
    908             } catch(IOException e){
    909                 System.out.println(tr("Warning: failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     908            } catch (IOException e){
     909                Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
    910910            }
    911911        }
     
    10061006            try {
    10071007                save();
    1008             } catch(IOException e){
    1009                 System.out.println(tr("Warning: failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1008            } catch (IOException e){
     1009                Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
    10101010            }
    10111011        }
     
    10751075            try {
    10761076                save();
    1077             } catch(IOException e){
    1078                 System.out.println(tr("Warning: failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1077            } catch (IOException e) {
     1078                Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
    10791079            }
    10801080        }
     
    16571657        for (String key : obsolete) {
    16581658            boolean removed = false;
    1659             if(properties.containsKey(key)) { properties.remove(key); removed = true; }
    1660             if(collectionProperties.containsKey(key)) { collectionProperties.remove(key); removed = true; }
    1661             if(arrayProperties.containsKey(key)) { arrayProperties.remove(key); removed = true; }
    1662             if(listOfStructsProperties.containsKey(key)) { listOfStructsProperties.remove(key); removed = true; }
    1663             if(removed)
    1664                 System.out.println(tr("Preference setting {0} has been removed since it is no longer used.", key));
     1659            if (properties.containsKey(key)) { properties.remove(key); removed = true; }
     1660            if (collectionProperties.containsKey(key)) { collectionProperties.remove(key); removed = true; }
     1661            if (arrayProperties.containsKey(key)) { arrayProperties.remove(key); removed = true; }
     1662            if (listOfStructsProperties.containsKey(key)) { listOfStructsProperties.remove(key); removed = true; }
     1663            if (removed) {
     1664                Main.info(tr("Preference setting {0} has been removed since it is no longer used.", key));
     1665            }
    16651666        }
    16661667    }
Note: See TracChangeset for help on using the changeset viewer.