PageRenderTime 3089ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/src/OConsoleLogManager.java

http://github.com/traitor/Minecraft-Server-Mod
Java | 38 lines | 32 code | 5 blank | 1 comment | 1 complexity | ddb245c55df69bfba90758bf31e60e4b MD5 | raw file
  1. import java.io.File;
  2. import java.util.logging.ConsoleHandler;
  3. import java.util.logging.FileHandler;
  4. import java.util.logging.Level;
  5. import java.util.logging.Logger;
  6. public class OConsoleLogManager {
  7. public static Logger a = Logger.getLogger("Minecraft");
  8. public static void a() {
  9. OConsoleLogFormatter localOConsoleLogFormatter = new OConsoleLogFormatter();
  10. a.setUseParentHandlers(false);
  11. ConsoleHandler localConsoleHandler = new ConsoleHandler();
  12. localConsoleHandler.setFormatter(localOConsoleLogFormatter);
  13. a.addHandler(localConsoleHandler);
  14. try {
  15. FileHandler localFileHandler = new FileHandler("server.log", true);
  16. localFileHandler.setFormatter(localOConsoleLogFormatter);
  17. a.addHandler(localFileHandler);
  18. } catch (Exception localException) {
  19. a.log(Level.WARNING, "Failed to log to server.log", localException);
  20. }
  21. // hMod: Keep the serveroutput logs.
  22. File log = new File("logs");
  23. try {
  24. if (!log.exists())
  25. log.mkdir();
  26. FileHandler localFileHandler = new FileHandler("logs/server_" + ((int) (System.currentTimeMillis() / 1000L)) + ".log");
  27. localFileHandler.setFormatter(localOConsoleLogFormatter);
  28. a.addHandler(localFileHandler);
  29. } catch (Exception localException) {
  30. a.log(Level.WARNING, "Failed to log to server log", localException);
  31. }
  32. }
  33. }