Changeset 6248 in josm for trunk/src/org/openstreetmap/josm/Main.java
- Timestamp:
- 2013-09-23T16:47:50+02:00 (13 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/Main.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r6143 r6248 41 41 import javax.swing.KeyStroke; 42 42 import javax.swing.UIManager; 43 import javax.swing.UnsupportedLookAndFeelException; 43 44 44 45 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; … … 199 200 200 201 /** 201 * Logging level (3 = debug, 2 = info, 1 = warn, 0 = none). 202 */ 203 static public int log_level = 2; 204 /** 205 * Print a warning message if logging is on. 202 * Logging level (4 = debug, 3 = info, 2 = warn, 1 = error, 0 = none). 203 * @since 6248 204 */ 205 public static int logLevel = 3; 206 207 /** 208 * Prints an error message if logging is on. 206 209 * @param msg The message to print. 207 */ 208 static public void warn(String msg) { 209 if (log_level < 1) 210 * @since 6248 211 */ 212 public static void error(String msg) { 213 if (logLevel < 1) 214 return; 215 System.err.println(tr("ERROR: {0}", msg)); 216 } 217 218 /** 219 * Prints a warning message if logging is on. 220 * @param msg The message to print. 221 */ 222 public static void warn(String msg) { 223 if (logLevel < 2) 210 224 return; 211 225 System.err.println(tr("WARNING: {0}", msg)); 212 226 } 213 /** 214 * Print an informational message if logging is on. 227 228 /** 229 * Prints an informational message if logging is on. 215 230 * @param msg The message to print. 216 231 */ 217 static public void info(String msg) {218 if (log _level <2)232 public static void info(String msg) { 233 if (logLevel < 3) 219 234 return; 220 System.err.println(tr("INFO: {0}", msg)); 221 } 222 /** 223 * Print an debug message if logging is on. 235 System.out.println(tr("INFO: {0}", msg)); 236 } 237 238 /** 239 * Prints a debug message if logging is on. 224 240 * @param msg The message to print. 225 241 */ 226 static public void debug(String msg) {227 if (log _level <3)242 public static void debug(String msg) { 243 if (logLevel < 4) 228 244 return; 229 System.err.println(tr("DEBUG: {0}", msg)); 230 } 231 /** 232 * Print a formated warning message if logging is on. Calls {@link MessageFormat#format} 245 System.out.println(tr("DEBUG: {0}", msg)); 246 } 247 248 /** 249 * Prints a formated error message if logging is on. Calls {@link MessageFormat#format} 233 250 * function to format text. 234 251 * @param msg The formated message to print. 235 252 * @param objects The objects to insert into format string. 236 */ 237 static public void warn(String msg, Object... objects) { 238 warn(MessageFormat.format(msg, objects)); 239 } 240 /** 241 * Print a formated informational message if logging is on. Calls {@link MessageFormat#format} 253 * @since 6248 254 */ 255 public static void error(String msg, Object... objects) { 256 error(MessageFormat.format(msg, objects)); 257 } 258 259 /** 260 * Prints a formated warning message if logging is on. Calls {@link MessageFormat#format} 242 261 * function to format text. 243 262 * @param msg The formated message to print. 244 263 * @param objects The objects to insert into format string. 245 264 */ 246 static public void info(String msg, Object... objects) { 247 info(MessageFormat.format(msg, objects)); 248 } 249 /** 250 * Print a formated debug message if logging is on. Calls {@link MessageFormat#format} 265 public static void warn(String msg, Object... objects) { 266 warn(MessageFormat.format(msg, objects)); 267 } 268 269 /** 270 * Prints a formated informational message if logging is on. Calls {@link MessageFormat#format} 251 271 * function to format text. 252 272 * @param msg The formated message to print. 253 273 * @param objects The objects to insert into format string. 254 274 */ 255 static public void debug(String msg, Object... objects) { 275 public static void info(String msg, Object... objects) { 276 info(MessageFormat.format(msg, objects)); 277 } 278 279 /** 280 * Prints a formated debug message if logging is on. Calls {@link MessageFormat#format} 281 * function to format text. 282 * @param msg The formated message to print. 283 * @param objects The objects to insert into format string. 284 */ 285 public static void debug(String msg, Object... objects) { 256 286 debug(MessageFormat.format(msg, objects)); 287 } 288 289 /** 290 * Prints an error message for the given Throwable. 291 * @param t The throwable object causing the error 292 * @since 6248 293 */ 294 public static void error(Throwable t) { 295 error(t.getClass().getName()+": "+t.getMessage()); 296 } 297 298 /** 299 * Prints a warning message for the given Throwable. 300 * @param t The throwable object causing the error 301 * @since 6248 302 */ 303 public static void warn(Throwable t) { 304 warn(t.getClass().getName()+": "+t.getMessage()); 257 305 } 258 306 … … 531 579 Object existing = inputMap.get(keyStroke); 532 580 if (existing != null && !existing.equals(action)) { 533 System.out.println(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action));581 info(String.format("Keystroke %s is already assigned to %s, will be overridden by %s", keyStroke, existing, action)); 534 582 } 535 583 inputMap.put(keyStroke, action); … … 600 648 UIManager.setLookAndFeel(laf); 601 649 } 602 catch (final java.lang.ClassNotFoundException e) {603 System.out.println("Look and Feel not found: " + laf);650 catch (final ClassNotFoundException e) { 651 info("Look and Feel not found: " + laf); 604 652 Main.pref.put("laf", defaultlaf); 605 653 } 606 catch (final javax.swing.UnsupportedLookAndFeelException e) {607 System.out.println("Look and Feel not supported: " + laf);654 catch (final UnsupportedLookAndFeelException e) { 655 info("Look and Feel not supported: " + laf); 608 656 Main.pref.put("laf", defaultlaf); 609 657 } … … 853 901 String os = System.getProperty("os.name"); 854 902 if (os == null) { 855 System.err.println("Your operating system has no name, so I'm guessing its some kind of *nix.");903 warn("Your operating system has no name, so I'm guessing its some kind of *nix."); 856 904 platform = new PlatformHookUnixoid(); 857 905 } else if (os.toLowerCase().startsWith("windows")) { … … 864 912 platform = new PlatformHookOsx(); 865 913 } else { 866 System.err.println("I don't know your operating system '"+os+"', so I'm guessing its some kind of *nix.");914 warn("I don't know your operating system '"+os+"', so I'm guessing its some kind of *nix."); 867 915 platform = new PlatformHookUnixoid(); 868 916 } … … 948 996 } 949 997 } 950 System.err.println("Error:Could not recognize Java Version: "+version);998 error("Could not recognize Java Version: "+version); 951 999 } 952 1000
Note:
See TracChangeset
for help on using the changeset viewer.
