diff --git a/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedLogger.java b/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedLogger.java index a71a40934..8b146c9c5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedLogger.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedLogger.java @@ -62,6 +62,11 @@ public class ConfigBasedLogger loggers.add(new WeakReference<>(this)); } + private static boolean isLessSpecificThan(Level _this, Level other) + { + return _this.intLevel() >= other.intLevel(); + } + private String _throwableToDetailString(Throwable t) { StringBuilder sb = new StringBuilder(); @@ -95,16 +100,16 @@ public class ConfigBasedLogger : this.logger.getMessageFactory().newMessage("{}", str); String msgStr = msg.getFormattedMessage(); - if (mode.levelForFile.isLessSpecificThan(level)) + if (isLessSpecificThan(mode.levelForFile, level)) { - Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level; + Level logLevel = isLessSpecificThan(level, Level.INFO) ? Level.INFO : level; if (param.length > 0 && param[param.length - 1] instanceof Throwable) logger.log(logLevel, msgStr, (Throwable) param[param.length - 1]); else logger.log(logLevel, msgStr); } - if (MC != null && mode.levelForChat.isLessSpecificThan(level)) + if (MC != null && isLessSpecificThan(mode.levelForChat, level)) { if (param.length > 0 && param[param.length - 1] instanceof Throwable) MC.logToChat(level, msgStr + "\n" + diff --git a/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedSpamLogger.java b/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedSpamLogger.java index db43ee3f5..06b3b1c3c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedSpamLogger.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/logging/ConfigBasedSpamLogger.java @@ -67,6 +67,11 @@ public class ConfigBasedSpamLogger loggers.add(new WeakReference<>(this)); } + private static boolean isLessSpecificThan(Level _this, Level other) + { + return _this.intLevel() >= other.intLevel(); + } + public void reset() { logTries.set(0); @@ -105,15 +110,15 @@ public class ConfigBasedSpamLogger Message msg = logger.getMessageFactory().newMessage(str, param); String msgStr = msg.getFormattedMessage(); - if (mode.levelForFile.isLessSpecificThan(level)) + if (isLessSpecificThan(mode.levelForFile, level)) { - Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level; + Level logLevel = isLessSpecificThan(level, Level.INFO) ? Level.INFO : level; if (param.length > 0 && param[param.length - 1] instanceof Throwable) logger.log(logLevel, msgStr, (Throwable) param[param.length - 1]); else logger.log(logLevel, msgStr); } - if (mode.levelForChat.isLessSpecificThan(level)) + if (isLessSpecificThan(mode.levelForChat, level)) { if (param.length > 0 && param[param.length - 1] instanceof Throwable) MC.logToChat(level, msgStr + "\n" + @@ -160,15 +165,15 @@ public class ConfigBasedSpamLogger Message msg = logger.getMessageFactory().newMessage(str, param); String msgStr = msg.getFormattedMessage(); - if (mode.levelForFile.isLessSpecificThan(level)) + if (isLessSpecificThan(mode.levelForFile, level)) { - Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level; + Level logLevel = isLessSpecificThan(level, Level.INFO) ? Level.INFO : level; if (param.length > 0 && param[param.length - 1] instanceof Throwable) logger.log(logLevel, msgStr, (Throwable) param[param.length - 1]); else logger.log(logLevel, msgStr); } - if (mode.levelForChat.isLessSpecificThan(level)) + if (isLessSpecificThan(mode.levelForChat, level)) { if (param.length > 0 && param[param.length - 1] instanceof Throwable) MC.logToChat(level, msgStr + "\n" + diff --git a/core/src/main/java/com/seibel/distanthorizons/core/logging/SpamReducedLogger.java b/core/src/main/java/com/seibel/distanthorizons/core/logging/SpamReducedLogger.java index b56263252..c96b46d15 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/logging/SpamReducedLogger.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/logging/SpamReducedLogger.java @@ -56,6 +56,11 @@ public class SpamReducedLogger loggers.add(new WeakReference(this)); } + private static boolean isLessSpecificThan(Level _this, Level other) + { + return _this.intLevel() >= other.intLevel(); + } + public void reset() { logTries.set(0); @@ -70,7 +75,7 @@ public class SpamReducedLogger { if (logTries.get() >= maxLogCount) return; - LOGGER.log(level.isLessSpecificThan(Level.INFO) ? Level.INFO : level, str, param); + LOGGER.log(isLessSpecificThan(level, Level.INFO) ? Level.INFO : level, str, param); } public void error(String str, Object... param) @@ -107,7 +112,7 @@ public class SpamReducedLogger { if (logTries.getAndIncrement() >= maxLogCount) return; - LOGGER.log(level.isLessSpecificThan(Level.INFO) ? Level.INFO : level, str, param); + LOGGER.log(isLessSpecificThan(level, Level.INFO) ? Level.INFO : level, str, param); } public void errorInc(String str, Object... param)