From f4cc4fb10825c2138d00e66fcb7c5baa6b58e227 Mon Sep 17 00:00:00 2001 From: Pahimar Date: Fri, 29 May 2015 19:47:51 -0400 Subject: [PATCH] Add debug config option to log all TRACE level events to INFO (if you ONLY want to see EE3 related TRACE stuff developers, enable this) --- .../com/pahimar/ee3/handler/ConfigurationHandler.java | 5 ++++- src/main/java/com/pahimar/ee3/reference/Messages.java | 4 ++++ src/main/java/com/pahimar/ee3/reference/Settings.java | 5 +++++ src/main/java/com/pahimar/ee3/util/LogHelper.java | 10 +++++++++- src/main/resources/assets/ee3/lang/en_US.lang | 3 +++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java index 2d3f9b7d..4ce9a7b4 100644 --- a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java @@ -15,11 +15,13 @@ public class ConfigurationHandler { public static Configuration configuration; + private final static String CATEGORY_DEBUG = "general.Debug"; + public static void init(File configFile) { if (configuration == null) { - configuration = new Configuration(configFile); + configuration = new Configuration(configFile, true); loadConfiguration(); } } @@ -31,6 +33,7 @@ public class ConfigurationHandler Settings.Sounds.soundMode = ConfigurationHelper.getString(configuration, Messages.Configuration.SOUND_MODE, Configuration.CATEGORY_GENERAL, "All", StatCollector.translateToLocal(Messages.Configuration.SOUND_MODE_COMMENT), new String[]{"All", "Self", "None"}, Messages.Configuration.SOUND_MODE_LABEL); Settings.Abilities.onlyLoadFile = configuration.getBoolean(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE, Configuration.CATEGORY_GENERAL, false, StatCollector.translateToLocal(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_COMMENT), Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_LABEL); Settings.DynamicEnergyValueGeneration.regenerateEnergyValuesWhen = ConfigurationHelper.getString(configuration, Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN, Configuration.CATEGORY_GENERAL, "When Mods Change", StatCollector.translateToLocal(Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_COMMENT), new String[]{"Never", "When Mods Change", "Always"}, Messages.Configuration.REGENERATE_ENERGYVALUES_WHEN_LABEL); + Settings.Debug.logTraceToInfo = configuration.getBoolean(Messages.Configuration.LOG_TRACE_TO_INFO, CATEGORY_DEBUG, false, StatCollector.translateToLocal(Messages.Configuration.LOG_TRACE_TO_INFO_COMMENT), Messages.Configuration.LOG_TRACE_TO_INFO_LABEL); if (configuration.hasChanged()) { diff --git a/src/main/java/com/pahimar/ee3/reference/Messages.java b/src/main/java/com/pahimar/ee3/reference/Messages.java index e098ace2..2f3a4efa 100644 --- a/src/main/java/com/pahimar/ee3/reference/Messages.java +++ b/src/main/java/com/pahimar/ee3/reference/Messages.java @@ -123,5 +123,9 @@ public final class Messages public static final String REGENERATE_ENERGYVALUES_WHEN = "energyvalues.regenerateEnergyValuesWhen"; public static final String REGENERATE_ENERGYVALUES_WHEN_LABEL = "general.energyvalues.regenerateEnergyValuesWhen.label"; public static final String REGENERATE_ENERGYVALUES_WHEN_COMMENT = "general.energyvalues.regenerateEnergyValuesWhen.comment"; + + public static final String LOG_TRACE_TO_INFO = "debug.logTraceToInfo"; + public static final String LOG_TRACE_TO_INFO_LABEL = "debug.logTraceToInfo.label"; + public static final String LOG_TRACE_TO_INFO_COMMENT = "debug.logTraceToInfo.comment"; } } diff --git a/src/main/java/com/pahimar/ee3/reference/Settings.java b/src/main/java/com/pahimar/ee3/reference/Settings.java index b12a0b63..471d98d9 100644 --- a/src/main/java/com/pahimar/ee3/reference/Settings.java +++ b/src/main/java/com/pahimar/ee3/reference/Settings.java @@ -21,4 +21,9 @@ public class Settings { public static String regenerateEnergyValuesWhen; } + + public static class Debug + { + public static boolean logTraceToInfo; + } } diff --git a/src/main/java/com/pahimar/ee3/util/LogHelper.java b/src/main/java/com/pahimar/ee3/util/LogHelper.java index 686c6cc7..dd77e391 100644 --- a/src/main/java/com/pahimar/ee3/util/LogHelper.java +++ b/src/main/java/com/pahimar/ee3/util/LogHelper.java @@ -1,6 +1,7 @@ package com.pahimar.ee3.util; import com.pahimar.ee3.reference.Reference; +import com.pahimar.ee3.reference.Settings; import cpw.mods.fml.common.FMLLog; import org.apache.logging.log4j.Level; @@ -43,7 +44,14 @@ public class LogHelper public static void trace(Object object) { - log(Level.TRACE, object); + if (!Settings.Debug.logTraceToInfo) + { + log(Level.TRACE, object); + } + else + { + log(Level.INFO, object); + } } public static void warn(Object object) diff --git a/src/main/resources/assets/ee3/lang/en_US.lang b/src/main/resources/assets/ee3/lang/en_US.lang index dfdbe0cf..adc70dd4 100644 --- a/src/main/resources/assets/ee3/lang/en_US.lang +++ b/src/main/resources/assets/ee3/lang/en_US.lang @@ -11,6 +11,9 @@ general.abilities.onlyLoadFile.comment=Setting this to true means that Abilities general.energyvalues.regenerateEnergyValuesWhen.label=Regenerate EnergyValues general.energyvalues.regenerateEnergyValuesWhen.comment=When to regenerate EnergyValues. Options are "Always" (every time Minecraft starts), "When Mods Change" (when mods are added, removed, or updated) or "Never" (only generate the first time). +debug.logTraceToInfo.label=Log TRACE to INFO +debug.logTraceToInfo.comment=Whether or not to log TRACE level logging events to INFO + # Keys key.categories.ee3=Equivalent Exchange 3 key.charge=Charge