コード例 #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
ファイル: 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;
  }
コード例 #3
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();
     }
   }
 }
コード例 #4
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();
 }
コード例 #5
0
ファイル: ConsoleManager.java プロジェクト: Raphfrk/Glowstone
 @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();
 }
コード例 #7
0
 @Override
 public void publish(LogRecord record) {
   if (!frame.isVisible()) return;
   super.publish(record);
   flush();
 }
コード例 #8
0
ファイル: ConsoleManager.java プロジェクト: BungMc/Bung
 @Override
 public synchronized void flush() {
   checkRotate();
   super.flush();
 }
コード例 #9
0
  public static void flush() {

    consoleHandler.flush();
  }
コード例 #10
0
 static {
   consoleHandler = new ConsoleHandler();
   consoleHandler.setFormatter(new SingleLineFormatter());
 }
コード例 #11
0
 /**
  * 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();
   }
 }
コード例 #12
0
 public synchronized void publish(LogRecord record) {
   super.publish(record);
   super.flush();
 }