示例#1
0
 @Override
 public synchronized void publish(LogRecord record) {
   if (!isLoggable(record)) {
     return;
   }
   checkRotate();
   super.publish(record);
   super.flush();
 }
示例#2
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;
  }
示例#3
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();
     }
   }
 }
示例#4
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();
 }
示例#5
0
 @Override
 public synchronized void flush() {
   if (!filename.equals(calculateFilename())) {
     filename = calculateFilename();
     server.getLogger().log(Level.INFO, "Log rotating to {0}...", filename);
     try {
       setOutputStream(new FileOutputStream(filename, true));
     } catch (FileNotFoundException ex) {
       server
           .getLogger()
           .log(
               Level.SEVERE,
               "Unable to open {0} for writing: {1}",
               new Object[] {filename, ex.getMessage()});
       ex.printStackTrace();
     }
   }
   super.flush();
 }
示例#6
0
 public void publish(LogRecord record) {
   super.publish(record);
   flush();
 }
 @Override
 public void publish(LogRecord record) {
   if (!frame.isVisible()) return;
   super.publish(record);
   flush();
 }
示例#8
0
 @Override
 public synchronized void flush() {
   checkRotate();
   super.flush();
 }
  public static void flush() {

    consoleHandler.flush();
  }
 static {
   consoleHandler = new ConsoleHandler();
   consoleHandler.setFormatter(new SingleLineFormatter());
 }
 /**
  * Publish a <tt>LogRecord</tt>.
  *
  * <p>The logging request was made initially to a <tt>Logger</tt> object, which initialized the
  * <tt>LogRecord</tt> and forwarded it here.
  *
  * <p>
  *
  * @param record description of the log event. A null record is silently ignored and is not
  *     published
  */
 public synchronized void publish(LogRecord record) {
   if (logThrottle == null || logThrottle.checkPublishLogRecordLocal()) {
     super.publish(record);
     flush();
   }
 }
 public synchronized void publish(LogRecord record) {
   super.publish(record);
   super.flush();
 }