From a4260ec4fd3343b1c9d7775e531ab6bc19f26177 Mon Sep 17 00:00:00 2001 From: StoneLabs Date: Wed, 25 Aug 2021 17:17:32 +0200 Subject: [PATCH] Use Logger instead of println --- src/main/java/net/fabricmc/example/ExampleMod.java | 7 ++++++- src/main/java/net/fabricmc/example/mixin/ExampleMixin.java | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/fabricmc/example/ExampleMod.java b/src/main/java/net/fabricmc/example/ExampleMod.java index e5ed082..1f97d1f 100644 --- a/src/main/java/net/fabricmc/example/ExampleMod.java +++ b/src/main/java/net/fabricmc/example/ExampleMod.java @@ -1,14 +1,19 @@ package net.fabricmc.example; import net.fabricmc.api.ModInitializer; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class ExampleMod implements ModInitializer { + public static final Logger LOGGER = LogManager.getLogger(); + @Override public void onInitialize() { // This code runs as soon as Minecraft is in a mod-load-ready state. // However, some things (like resources) may still be uninitialized. // Proceed with mild caution. - System.out.println("Hello Fabric world!"); + LOGGER.log(Level.INFO, "Hello Fabric world!"); } } diff --git a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java b/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java index 83ee1a8..1aca2bb 100644 --- a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java +++ b/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java @@ -1,6 +1,8 @@ package net.fabricmc.example.mixin; +import net.fabricmc.example.ExampleMod; import net.minecraft.client.gui.screen.TitleScreen; +import org.apache.logging.log4j.Level; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -10,6 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class ExampleMixin { @Inject(at = @At("HEAD"), method = "init()V") private void init(CallbackInfo info) { - System.out.println("This line is printed by an example mod mixin!"); + ExampleMod.LOGGER.log(Level.INFO, "This line is printed by an example mod mixin!"); } }