コード例 #1
0
ファイル: ConsoleManager.java プロジェクト: BungMc/Bung
 @Override
 public synchronized void publish(LogRecord record) {
   if (!isLoggable(record)) {
     return;
   }
   checkRotate();
   super.publish(record);
   super.flush();
 }
コード例 #2
0
 /**
  * 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();
 }
コード例 #3
0
ファイル: LiteLoader.java プロジェクト: Nanonid/liteloader
  /** 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;
  }
コード例 #4
0
ファイル: ConsoleManager.java プロジェクト: BungMc/Bung
 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();
     }
   }
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
ファイル: ConsoleManager.java プロジェクト: kitskub/Glowstone
 @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();
 }
コード例 #7
0
ファイル: ConsoleManager.java プロジェクト: BungMc/Bung
 @Override
 public synchronized void flush() {
   checkRotate();
   super.flush();
 }