Esempio n. 1
0
 @Override
 public synchronized void publish(LogRecord record) {
   if (!isLoggable(record)) {
     return;
   }
   checkRotate();
   super.publish(record);
   super.flush();
 }
 /**
  * Format and publish a <tt>LogRecord</tt>.
  *
  * @param record description of the log event. A null record is silently ignored and is not
  *     published
  */
 public synchronized void publish(LogRecord record) {
   if (!isLoggable(record)) {
     return;
   }
   super.publish(record);
   flush();
 }
Esempio n. 3
0
  /** Set up reflection methods required by the loader */
  @SuppressWarnings("unchecked")
  private boolean prepareLoader() {
    try {
      // addURL method is used by the class loader to
      mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
      mAddUrl.setAccessible(true);

      Formatter minecraftLogFormatter = null;

      try {
        Class<? extends Formatter> formatterClass =
            (Class<? extends Formatter>)
                Minecraft.class
                    .getClassLoader()
                    .loadClass(
                        ModUtilities.getObfuscatedFieldName(
                            "net.minecraft.src.ConsoleLogFormatter", "em"));
        Constructor<? extends Formatter> defaultConstructor =
            formatterClass.getDeclaredConstructor();
        defaultConstructor.setAccessible(true);
        minecraftLogFormatter = defaultConstructor.newInstance();
      } catch (Exception ex) {
        ConsoleLogManager.init();
        minecraftLogFormatter = ConsoleLogManager.loggerLogManager.getHandlers()[0].getFormatter();
      }

      logger.setUseParentHandlers(false);

      StreamHandler consoleHandler = new ConsoleHandler();
      if (minecraftLogFormatter != null) consoleHandler.setFormatter(minecraftLogFormatter);
      logger.addHandler(consoleHandler);

      FileHandler logFileHandler =
          new FileHandler(
              new File(Minecraft.getMinecraftDir(), "LiteLoader.txt").getAbsolutePath());
      if (minecraftLogFormatter != null) logFileHandler.setFormatter(minecraftLogFormatter);
      logger.addHandler(logFileHandler);
    } catch (Throwable th) {
      logger.log(Level.SEVERE, "Error initialising LiteLoader", th);
      return false;
    }

    return true;
  }
Esempio n. 4
0
 private void checkRotate() {
   if (rotate) {
     String newFilename = calculateFilename();
     if (!filename.equals(newFilename)) {
       filename = newFilename;
       // note that the console handler doesn't see this message
       super.publish(new LogRecord(Level.INFO, "Log rotating to: " + filename));
       updateOutput();
     }
   }
 }
 /**
  * Close this output stream.
  *
  * @exception SecurityException if a security manager exists and if the caller does not have
  *     <tt>LoggingPermission("control")</tt>.
  */
 public synchronized void close() throws SecurityException {
   super.close();
   if (sock != null) {
     try {
       sock.close();
     } catch (IOException ix) {
       // drop through.
     }
   }
   sock = null;
 }
Esempio n. 6
0
 @Override
 public synchronized void flush() {
   if (rotate) {
     String newFilename = calculateFilename();
     if (!filename.equals(newFilename)) {
       filename = newFilename;
       logger.log(Level.INFO, "Log rotating to {0}...", filename);
       updateOutput();
     }
   }
   super.flush();
 }
Esempio n. 7
0
 @Override
 public synchronized void flush() {
   checkRotate();
   super.flush();
 }