/src/test/java/com/onarandombox/multiverseinventories/util/Util.java

https://gitlab.com/kidaa/Multiverse-Inventories · Java · 62 lines · 40 code · 15 blank · 7 comment · 1 complexity · f85e51aaca6852b44f3a378c432f1055 MD5 · raw file

  1. /******************************************************************************
  2. * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
  3. * Multiverse 2 is licensed under the BSD License. *
  4. * For more information please check the README.md file included *
  5. * with this project. *
  6. ******************************************************************************/
  7. package com.onarandombox.multiverseinventories.util;
  8. import com.dumptruckman.minecraft.util.Logging;
  9. import java.util.logging.ConsoleHandler;
  10. import java.util.logging.Handler;
  11. import java.util.logging.Level;
  12. import java.util.logging.LogRecord;
  13. import java.util.logging.Logger;
  14. public class Util {
  15. private Util() {}
  16. //public static final Logger logger = Logger.getLogger("MV-Test");
  17. public static final Logger logger = Logging.getLogger();
  18. static {
  19. logger.setUseParentHandlers(false);
  20. Handler handler = new ConsoleHandler();
  21. handler.setFormatter(new MVTestLogFormatter());
  22. Handler[] handlers = logger.getHandlers();
  23. for (Handler h : handlers)
  24. logger.removeHandler(h);
  25. logger.addHandler(handler);
  26. }
  27. public static void log(Throwable t) {
  28. log(Level.WARNING, t.getLocalizedMessage(), t);
  29. }
  30. public static void log(Level level, Throwable t) {
  31. log(level, t.getLocalizedMessage(), t);
  32. }
  33. public static void log(String message, Throwable t) {
  34. log(Level.WARNING, message, t);
  35. }
  36. public static void log(Level level, String message, Throwable t) {
  37. LogRecord record = new LogRecord(level, message);
  38. record.setThrown(t);
  39. logger.log(record);
  40. }
  41. public static void log(String message) {
  42. log(Level.INFO, message);
  43. }
  44. public static void log(Level level, String message) {
  45. logger.log(level, message);
  46. }
  47. }