Skip to content

Commit c75ed0c

Browse files
committed
override log level properly #244
The default behavior of forge is to log debug messages to a debug.log. Torchmaster can be quiet verbose when it comes to logging on debug. Since these logs are usually useless during normal play, they will be force-disabled now using Configurator.setLevel(logger, level). If debug logging is required, launch the game with `-Dtorchmaster.enableDebugLogging=1`
1 parent 572490e commit c75ed0c

File tree

7 files changed

+18
-67
lines changed

7 files changed

+18
-67
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## v21.1.5
2+
- Remove spawn logging in debug log by default to reduce potential wear on storage drives on both fabric and neoforge. \
3+
\
4+
The default behavior for modded minecraft is to log debug messages to a debug.log.
5+
Torchmaster can be quite verbose when it comes to logging on debug.
6+
Since these logs are usually useless during normal play, they will be force-disabled be default (only for torchmaster).
7+
If debug logging is required, launch the game with `-Dtorchmaster.enableDebugLogging=1`
8+
19
## v21.1.4
210
- Fix crash during setup of a village siege on fabric
311
- Add missing torchmaster command from previous versions
@@ -24,4 +32,4 @@
2432
- Update to MC 1.21.1
2533

2634
## v21.0.0
27-
- First release for Minecraft 1.21 (Fabric, Neoforge)
35+
- First release for Minecraft 1.21 (Fabric, Neoforge)7

common/src/main/java/net/xalcon/torchmaster/LogHax.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

common/src/main/java/net/xalcon/torchmaster/Torchmaster.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.xalcon.torchmaster.logic.entityblocking.FilteredLightManager;
99
import net.xalcon.torchmaster.logic.entityblocking.IBlockingLightManager;
1010
import net.xalcon.torchmaster.platform.Services;
11+
import org.apache.logging.log4j.core.config.Configurator;
1112
import org.slf4j.Logger;
1213
import org.slf4j.LoggerFactory;
1314

@@ -33,16 +34,19 @@ public static ITorchmasterConfig getConfig()
3334
// write the majority of your code here and load it from your loader specific projects. This example has some
3435
// code that gets invoked by the entry point of the loader specific projects.
3536
public static void init() {
36-
ModRegistry.initialize();
37-
3837
if(System.getProperty("torchmaster.enableDebugLogging", "0").equals("1"))
3938
{
40-
LogHax.enableDebugLogging(Torchmaster.LOG);
39+
Configurator.setLevel(Constants.MOD_NAME, org.apache.logging.log4j.Level.DEBUG);
4140
}
4241
else
4342
{
44-
LogHax.disableDebugLogging(Torchmaster.LOG);
43+
Configurator.setLevel(Constants.MOD_NAME, org.apache.logging.log4j.Level.INFO);
4544
}
45+
46+
LOG.info("Initializing Torchmaster for platform {}", Services.PLATFORM.getPlatformName());
47+
LOG.info("Debug Logging Enabled: {}", LOG.isDebugEnabled());
48+
LOG.debug("If you can see this while the system property torchmaster.enableDebugLogging is not set to 1, report this on github!");
49+
ModRegistry.initialize();
4650
}
4751

4852
public static Optional<IBlockingLightManager> getRegistryForLevel(Level level)

fabric/src/main/java/net/xalcon/torchmaster/TorchmasterFabric.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public void onInitialize() {
1818
// project.
1919

2020
// Use Fabric to bootstrap the Common mod.
21-
Torchmaster.LOG.info("Hello Fabric world!");
2221
Torchmaster.init();
2322

2423
ServerWorldEvents.LOAD.register((server, world) ->

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Every field you add must be added to the root build.gradle expandProps map.
33

44
# Project
5-
version=21.1.4-beta
5+
version=21.1.5-beta
66
group=net.xalcon.torchmaster
77
java_version=21
88

neoforge/src/main/java/net/xalcon/torchmaster/TorchmasterNeoforge.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public TorchmasterNeoforge(ModContainer container, IEventBus eventBus) {
3232
container.registerConfig(ModConfig.Type.COMMON, TorchmasterNeoforgeConfig.spec, "torchmaster.toml");
3333

3434
// Use NeoForge to bootstrap the Common mod.
35-
Torchmaster.LOG.info("Hello NeoForge world!");
3635
Torchmaster.init();
3736
}
3837

neoforge/src/main/java/net/xalcon/torchmaster/TorchmasterNeoforgeConfig.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public static class General
4040
public final ModConfigSpec.ConfigValue<Integer> frozenPearlDurability;
4141
public final ModConfigSpec.ConfigValue<Boolean> aggressiveSpawnChecks;
4242

43-
public final ModConfigSpec.ConfigValue<Boolean> logSpawnChecks;
44-
4543
private General(ModConfigSpec.Builder builder)
4644
{
4745
builder.push("General");
@@ -126,11 +124,6 @@ private General(ModConfigSpec.Builder builder)
126124
.translation("torchmaster.config.frozenPearlDurability.description")
127125
.defineInRange("frozenPearlDurability", 1024, 0, Short.MAX_VALUE);
128126

129-
logSpawnChecks = builder
130-
.comment("Print entity spawn checks to the debug log")
131-
.translation("torchmaster.config.logSpawnChecks.description")
132-
.define("logSpawnChecks", false);
133-
134127
aggressiveSpawnChecks = builder
135128
.comment("Configures the spawn check to be more aggressive, effectivly overriding the CheckSpawn results of other mods")
136129
.translation("torchmaster.config.aggressiveSpawnChecks.description")

0 commit comments

Comments
 (0)