diff --git a/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java b/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java index c21e2ac..16d6e69 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java @@ -3,6 +3,7 @@ import dev.upcraft.sparkweave.api.SparkweaveApi; import dev.upcraft.sparkweave.api.entrypoint.MainEntryPoint; import dev.upcraft.sparkweave.api.event.CommandEvents; +import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; import dev.upcraft.sparkweave.api.platform.ModContainer; import dev.upcraft.sparkweave.api.platform.services.RegistryService; import dev.upcraft.sparkweave.api.registry.RegistryHandler; @@ -11,6 +12,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.Logger; import java.util.List; import java.util.stream.Stream; @@ -18,6 +20,7 @@ public class SparkweaveMod implements MainEntryPoint { public static final String MODID = "sparkweave"; + private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger(); @Override public void onInitialize(ModContainer mod) { @@ -39,4 +42,8 @@ public static List ids(String... paths) { Validate.notEmpty(paths, "Must provide at least 1 ID!"); return Stream.of(paths).map(SparkweaveMod::id).toList(); } + + public static void onLoadComplete() { + LOGGER.debug("System initialized!"); + } } diff --git a/Common/src/main/java/dev/upcraft/sparkweave/client/render/RenderDocHelper.java b/Common/src/main/java/dev/upcraft/sparkweave/client/render/RenderDocHelper.java index fecc08d..a4d5412 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/client/render/RenderDocHelper.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/client/render/RenderDocHelper.java @@ -3,7 +3,7 @@ import dev.upcraft.sparkweave.SparkweaveMod; import dev.upcraft.sparkweave.api.SparkweaveApi; import dev.upcraft.sparkweave.api.annotation.Mod; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; +import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; import org.apache.logging.log4j.Logger; import java.io.File; @@ -13,7 +13,7 @@ @Mod.Context(SparkweaveMod.MODID) public class RenderDocHelper { - private static final Logger LOGGER = SparkweaveLogging.getLogger(); + private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger(); public static void init() { if(SparkweaveApi.Client.LOAD_RENDERDOC) { diff --git a/Common/src/main/java/dev/upcraft/sparkweave/command/DumpRegistryCommand.java b/Common/src/main/java/dev/upcraft/sparkweave/command/DumpRegistryCommand.java index 36c9edd..0eda1be 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/command/DumpRegistryCommand.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/command/DumpRegistryCommand.java @@ -7,9 +7,9 @@ import dev.upcraft.sparkweave.SparkweaveMod; import dev.upcraft.sparkweave.api.command.CommandHelper; import dev.upcraft.sparkweave.api.command.argument.RegistryArgumentType; +import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; import dev.upcraft.sparkweave.api.platform.Services; import dev.upcraft.sparkweave.api.serialization.CSVWriter; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -19,6 +19,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.resources.ResourceKey; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.Files; @@ -26,6 +27,8 @@ public class DumpRegistryCommand { + private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger(); + public static void register(LiteralArgumentBuilder $) { $.then(Commands.literal("dump_registries") .requires(src -> src.hasPermission(Commands.LEVEL_OWNERS)) @@ -97,7 +100,7 @@ private static void saveRegistryToFile(HolderLookup.RegistryLookup lookup, Pa } } } catch (IOException e) { - SparkweaveLogging.getLogger().error("Failed to write registry dump for {}", lookup.key().location(), e); + LOGGER.error("Failed to write registry dump for {}", lookup.key().location(), e); throw CommandHelper.IO_EXCEPTION.create(e.getMessage()); } } diff --git a/Common/src/main/java/dev/upcraft/sparkweave/logging/SparkweaveLogging.java b/Common/src/main/java/dev/upcraft/sparkweave/logging/SparkweaveLogging.java deleted file mode 100644 index bc949ef..0000000 --- a/Common/src/main/java/dev/upcraft/sparkweave/logging/SparkweaveLogging.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.upcraft.sparkweave.logging; - -import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; -import org.apache.logging.log4j.Logger; - -public class SparkweaveLogging { - private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger(); - - public static Logger getLogger() { - return LOGGER; - } -} diff --git a/Common/src/main/java/dev/upcraft/sparkweave/platform/DotEnv.java b/Common/src/main/java/dev/upcraft/sparkweave/platform/DotEnv.java index 4a8d9ec..58b17d3 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/platform/DotEnv.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/platform/DotEnv.java @@ -1,7 +1,8 @@ package dev.upcraft.sparkweave.platform; +import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; import dev.upcraft.sparkweave.api.platform.Services; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.Files; @@ -9,6 +10,8 @@ public class DotEnv { + private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger("Sparkweave Engine/DotEnv"); + public static void load(Path path) { if(!Files.isRegularFile(path)) { return; @@ -16,7 +19,7 @@ public static void load(Path path) { try (var reader = Files.newBufferedReader(path)) { System.getProperties().load(reader); } catch (IOException e) { - SparkweaveLogging.getLogger().error("Unable to load env file: {}", path.toAbsolutePath(), e); + LOGGER.error("Unable to load env file: {}", path.toAbsolutePath(), e); } } diff --git a/Common/src/main/java/dev/upcraft/sparkweave/validation/TranslationChecker.java b/Common/src/main/java/dev/upcraft/sparkweave/validation/TranslationChecker.java index a0dca46..2f14b64 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/validation/TranslationChecker.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/validation/TranslationChecker.java @@ -1,8 +1,9 @@ package dev.upcraft.sparkweave.validation; import dev.upcraft.sparkweave.api.SparkweaveApi; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; +import dev.upcraft.sparkweave.api.logging.SparkweaveLoggerFactory; import net.minecraft.server.Bootstrap; +import org.apache.logging.log4j.Logger; import java.util.Collections; import java.util.HashSet; @@ -12,11 +13,12 @@ public class TranslationChecker { private static final Set MISSING_KEYS = new HashSet<>(); private static final Set MISSING_KEYS_VIEW = Collections.unmodifiableSet(MISSING_KEYS); + private static final Logger LOGGER = SparkweaveLoggerFactory.getLogger("Sparkweave Engine/TranslationChecker"); private static void notifyMissingTranslation(String translationKey) { if(!MISSING_KEYS.contains(translationKey)) { if(SparkweaveApi.Client.LOG_MISSING_TRANSLATIONS) { - SparkweaveLogging.getLogger().warn("Missing translation for key '{}'", translationKey); + LOGGER.warn("Missing translation for key '{}'", translationKey); } MISSING_KEYS.add(translationKey); } diff --git a/Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Main.java b/Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Main.java index c89c9f7..c549fdb 100644 --- a/Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Main.java +++ b/Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Main.java @@ -1,12 +1,12 @@ package dev.upcraft.sparkweave.fabric.entrypoint; +import dev.upcraft.sparkweave.SparkweaveMod; import dev.upcraft.sparkweave.api.annotation.CalledByReflection; import dev.upcraft.sparkweave.api.entrypoint.MainEntryPoint; import dev.upcraft.sparkweave.api.event.CommandEvents; import dev.upcraft.sparkweave.api.platform.services.RegistryService; import dev.upcraft.sparkweave.api.registry.block.BlockItemProvider; import dev.upcraft.sparkweave.entrypoint.EntrypointHelper; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; import dev.upcraft.sparkweave.registry.SparkweaveCommandArgumentTypes; import dev.upcraft.sparkweave.scheduler.ScheduledTaskQueue; import net.fabricmc.api.ModInitializer; @@ -51,6 +51,6 @@ public T accept(Function factory, Supplier< EntrypointHelper.fireEntrypoints(MainEntryPoint.class, MainEntryPoint::onInitialize); - SparkweaveLogging.getLogger().debug("System initialized!"); + SparkweaveMod.onLoadComplete(); } } diff --git a/NeoForge/src/main/java/dev/upcraft/sparkweave/neoforge/entrypoint/Main.java b/NeoForge/src/main/java/dev/upcraft/sparkweave/neoforge/entrypoint/Main.java index 531dde8..13ddef1 100644 --- a/NeoForge/src/main/java/dev/upcraft/sparkweave/neoforge/entrypoint/Main.java +++ b/NeoForge/src/main/java/dev/upcraft/sparkweave/neoforge/entrypoint/Main.java @@ -8,7 +8,6 @@ import dev.upcraft.sparkweave.api.platform.services.RegistryService; import dev.upcraft.sparkweave.api.registry.block.BlockItemProvider; import dev.upcraft.sparkweave.entrypoint.EntrypointHelper; -import dev.upcraft.sparkweave.logging.SparkweaveLogging; import dev.upcraft.sparkweave.registry.SparkweaveCommandArgumentTypes; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; @@ -42,7 +41,7 @@ public Main(IEventBus bus) { EntrypointHelper.fireEntrypoints(DedicatedServerEntryPoint.class, DedicatedServerEntryPoint::onInitializeServer); } - SparkweaveLogging.getLogger().debug("System initialized!"); + SparkweaveMod.onLoadComplete(); } @SubscribeEvent