Skip to content

Commit

Permalink
override log level properly #244
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Xalcon committed Oct 20, 2024
1 parent 572490e commit c75ed0c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 67 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v21.1.5
- Remove spawn logging in debug log by default to reduce potential wear on storage drives on both fabric and neoforge. \
\
The default behavior for modded minecraft is to log debug messages to a debug.log.
Torchmaster can be quite verbose when it comes to logging on debug.
Since these logs are usually useless during normal play, they will be force-disabled be default (only for torchmaster).
If debug logging is required, launch the game with `-Dtorchmaster.enableDebugLogging=1`

## v21.1.4
- Fix crash during setup of a village siege on fabric
- Add missing torchmaster command from previous versions
Expand All @@ -24,4 +32,4 @@
- Update to MC 1.21.1

## v21.0.0
- First release for Minecraft 1.21 (Fabric, Neoforge)
- First release for Minecraft 1.21 (Fabric, Neoforge)7
52 changes: 0 additions & 52 deletions common/src/main/java/net/xalcon/torchmaster/LogHax.java

This file was deleted.

12 changes: 8 additions & 4 deletions common/src/main/java/net/xalcon/torchmaster/Torchmaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.xalcon.torchmaster.logic.entityblocking.FilteredLightManager;
import net.xalcon.torchmaster.logic.entityblocking.IBlockingLightManager;
import net.xalcon.torchmaster.platform.Services;
import org.apache.logging.log4j.core.config.Configurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,16 +34,19 @@ public static ITorchmasterConfig getConfig()
// write the majority of your code here and load it from your loader specific projects. This example has some
// code that gets invoked by the entry point of the loader specific projects.
public static void init() {
ModRegistry.initialize();

if(System.getProperty("torchmaster.enableDebugLogging", "0").equals("1"))
{
LogHax.enableDebugLogging(Torchmaster.LOG);
Configurator.setLevel(Constants.MOD_NAME, org.apache.logging.log4j.Level.DEBUG);
}
else
{
LogHax.disableDebugLogging(Torchmaster.LOG);
Configurator.setLevel(Constants.MOD_NAME, org.apache.logging.log4j.Level.INFO);
}

LOG.info("Initializing Torchmaster for platform {}", Services.PLATFORM.getPlatformName());
LOG.info("Debug Logging Enabled: {}", LOG.isDebugEnabled());
LOG.debug("If you can see this while the system property torchmaster.enableDebugLogging is not set to 1, report this on github!");
ModRegistry.initialize();
}

public static Optional<IBlockingLightManager> getRegistryForLevel(Level level)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public void onInitialize() {
// project.

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

ServerWorldEvents.LOAD.register((server, world) ->
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Every field you add must be added to the root build.gradle expandProps map.

# Project
version=21.1.4-beta
version=21.1.5-beta
group=net.xalcon.torchmaster
java_version=21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public TorchmasterNeoforge(ModContainer container, IEventBus eventBus) {
container.registerConfig(ModConfig.Type.COMMON, TorchmasterNeoforgeConfig.spec, "torchmaster.toml");

// Use NeoForge to bootstrap the Common mod.
Torchmaster.LOG.info("Hello NeoForge world!");
Torchmaster.init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public static class General
public final ModConfigSpec.ConfigValue<Integer> frozenPearlDurability;
public final ModConfigSpec.ConfigValue<Boolean> aggressiveSpawnChecks;

public final ModConfigSpec.ConfigValue<Boolean> logSpawnChecks;

private General(ModConfigSpec.Builder builder)
{
builder.push("General");
Expand Down Expand Up @@ -126,11 +124,6 @@ private General(ModConfigSpec.Builder builder)
.translation("torchmaster.config.frozenPearlDurability.description")
.defineInRange("frozenPearlDurability", 1024, 0, Short.MAX_VALUE);

logSpawnChecks = builder
.comment("Print entity spawn checks to the debug log")
.translation("torchmaster.config.logSpawnChecks.description")
.define("logSpawnChecks", false);

aggressiveSpawnChecks = builder
.comment("Configures the spawn check to be more aggressive, effectivly overriding the CheckSpawn results of other mods")
.translation("torchmaster.config.aggressiveSpawnChecks.description")
Expand Down

0 comments on commit c75ed0c

Please sign in to comment.