Exemplo n.º 1
0
 private void setDefaultLogging() {
   Thread.setDefaultUncaughtExceptionHandler(
       new Thread.UncaughtExceptionHandler() {
         @Override
         public void uncaughtException(Thread t, Throwable e) {
           Logger logger = LoggerFactory.getLogger(t.getClass());
           logger.error("Exception in thread [" + t.getName() + "]", e);
           PrideInspector.this
               .getDesktopContext()
               .addThrowableEntry(
                   new ThrowableEntry(MessageType.ERROR, "Unexpected Exception", e));
         }
       });
 }
Exemplo n.º 2
0
 private void installDefaultExceptionHandler() {
   Thread.setDefaultUncaughtExceptionHandler(
       new Thread.UncaughtExceptionHandler() {
         public void uncaughtException(Thread t, final Throwable e) {
           SwingUtilities.invokeLater(
               new Runnable() {
                 @Override
                 public void run() {
                   ExceptionDialog d = new ExceptionDialog(null, e);
                   d.setVisible(true);
                 }
               });
         }
       });
 }
Exemplo n.º 3
0
  protected static Logger setupLogger() {
    final Logger logger = Utils.getLogger();
    File logDirectory = new File(Utils.getLauncherDirectory(), "logs");
    if (!logDirectory.exists()) {
      logDirectory.mkdir();
    }
    File logs = new File(logDirectory, "lovelauncher_%D.log");
    RotatingFileHandler fileHandler = new RotatingFileHandler(logs.getPath());

    fileHandler.setFormatter(new TechnicLogFormatter());

    for (Handler h : logger.getHandlers()) {
      logger.removeHandler(h);
    }
    logger.addHandler(fileHandler);

    SpoutcraftLauncher.handler = fileHandler;

    if (params != null && !params.isDebugMode()) {
      logger.setUseParentHandlers(false);

      System.setOut(new PrintStream(new LoggerOutputStream(console, Level.INFO, logger), true));
      System.setErr(new PrintStream(new LoggerOutputStream(console, Level.SEVERE, logger), true));
    }

    Thread.setDefaultUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(Thread t, Throwable e) {
            logger.log(Level.SEVERE, "Unhandled Exception in " + t, e);

            if (errorDialog == null) {
              LauncherFrame frame = null;

              try {
                frame = Launcher.getFrame();
              } catch (Exception ex) {
                // This can happen if we have a very early crash- before Launcher initializes
              }

              errorDialog = new ErrorDialog(frame, e);
              errorDialog.setVisible(true);
            }
          }
        });

    return logger;
  }