Ignore:
Timestamp:
2013-09-23T16:47:50+02:00 (13 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/AutosaveTask.java

    r6104 r6248  
    8989
    9090            if (!autosaveDir.exists() && !autosaveDir.mkdirs()) {
    91                 System.out.println(tr("Unable to create directory {0}, autosave will be disabled", autosaveDir.getAbsolutePath()));
     91                Main.warn(tr("Unable to create directory {0}, autosave will be disabled", autosaveDir.getAbsolutePath()));
    9292                return;
    9393            }
    9494            if (!deletedLayersDir.exists() && !deletedLayersDir.mkdirs()) {
    95                 System.out.println(tr("Unable to create directory {0}, autosave will be disabled", deletedLayersDir.getAbsolutePath()));
     95                Main.warn(tr("Unable to create directory {0}, autosave will be disabled", deletedLayersDir.getAbsolutePath()));
    9696                return;
    9797            }
     
    159159                        Utils.close(ps);
    160160                    } catch (Throwable t) {
    161                         System.err.println(t.getMessage());
     161                        Main.error(t);
    162162                    }
    163163                    return result;
    164164                } else {
    165                     System.out.println(tr("Unable to create file {0}, other filename will be used", result.getAbsolutePath()));
     165                    Main.warn(tr("Unable to create file {0}, other filename will be used", result.getAbsolutePath()));
    166166                    if (index > PROP_INDEX_LIMIT.get())
    167167                        throw new IOException("index limit exceeded");
    168168                }
    169169            } catch (IOException e) {
    170                 System.err.println(tr("IOError while creating file, autosave will be skipped: {0}", e.getMessage()));
     170                Main.error(tr("IOError while creating file, autosave will be skipped: {0}", e.getMessage()));
    171171                return null;
    172172            }
     
    190190            File oldFile = info.backupFiles.remove();
    191191            if (!oldFile.delete()) {
    192                 System.out.println(tr("Unable to delete old backup file {0}", oldFile.getAbsolutePath()));
     192                Main.warn(tr("Unable to delete old backup file {0}", oldFile.getAbsolutePath()));
    193193            } else {
    194194                getPidFile(oldFile).delete();
     
    207207            } catch (Throwable t) {
    208208                // Don't let exception stop time thread
    209                 System.err.println("Autosave failed: ");
     209                Main.error("Autosave failed:");
     210                Main.error(t);
    210211                t.printStackTrace();
    211212            }
     
    257258                            }
    258259                        } catch (IOException e) {
    259                             System.err.println(tr("Error while creating backup of removed layer: {0}", e.getMessage()));
     260                            Main.error(tr("Error while creating backup of removed layer: {0}", e.getMessage()));
    260261                        }
    261262
     
    300301                            }
    301302                        } catch (Throwable t) {
    302                             System.err.println(t.getClass()+":"+t.getMessage());
     303                            Main.error(t);
    303304                        } finally {
    304305                            Utils.close(reader);
    305306                        }
    306307                    } catch (Throwable t) {
    307                         System.err.println(t.getClass()+":"+t.getMessage());
     308                        Main.error(t);
    308309                    }
    309310                }
     
    359360            deletedLayers.remove(backupFile);
    360361            if (!backupFile.delete()) {
    361                 System.err.println(String.format("Warning: Could not delete old backup file %s", backupFile));
     362                Main.warn(String.format("Could not delete old backup file %s", backupFile));
    362363            }
    363364        }
     
    366367            pidFile.delete();
    367368        } else {
    368             System.err.println(String.format("Warning: Could not move autosaved file %s to %s folder", f.getName(), deletedLayersDir.getName()));
     369            Main.warn(String.format("Could not move autosaved file %s to %s folder", f.getName(), deletedLayersDir.getName()));
    369370            // we cannot move to deleted folder, so just try to delete it directly
    370371            if (!f.delete()) {
    371                 System.err.println(String.format("Warning: Could not delete backup file %s", f));
     372                Main.warn(String.format("Could not delete backup file %s", f));
    372373            } else {
    373374                pidFile.delete();
     
    380381            }
    381382            if (!next.delete()) {
    382                 System.err.println(String.format("Warning: Could not delete archived backup file %s", next));
     383                Main.warn(String.format("Could not delete archived backup file %s", next));
    383384            }
    384385        }
Note: See TracChangeset for help on using the changeset viewer.