summary refs log tree commit diff stats
path: root/src/main/java/net/fabricmc
diff options
context:
space:
mode:
authorLevy Ehrstein <levyehrstein@googlemail.com>2021-09-22 13:25:04 +0200
committerGitHub <noreply@github.com>2021-09-22 12:25:04 +0100
commit3829e2132d320f523565aff3c91716151028597c (patch)
tree153b940a45983dc71a1ac6bca4db92b7109e7b5f /src/main/java/net/fabricmc
parent9df9227ee7bc0cca03f248d322941ddb1dcaaed6 (diff)
Use Logger instead of println (#126)
Diffstat (limited to 'src/main/java/net/fabricmc')
-rw-r--r--src/main/java/net/fabricmc/example/ExampleMod.java9
-rw-r--r--src/main/java/net/fabricmc/example/mixin/ExampleMixin.java3
2 files changed, 10 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..ad43b69 100644
--- a/src/main/java/net/fabricmc/example/ExampleMod.java
+++ b/src/main/java/net/fabricmc/example/ExampleMod.java
@@ -1,14 +1,21 @@
 package net.fabricmc.example;
 
 import net.fabricmc.api.ModInitializer;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 public class ExampleMod implements ModInitializer {
+	// This logger is used to write text to the console and the log file.
+	// It is considered best practice to use your mod id as the logger's name.
+	// That way, it's clear which mod wrote info, warnings, and errors.
+	public static final Logger LOGGER = LogManager.getLogger("modid");
+
 	@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.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..356cb38 100644
--- a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java
+++ b/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java
@@ -1,5 +1,6 @@
 package net.fabricmc.example.mixin;
 
+import net.fabricmc.example.ExampleMod;
 import net.minecraft.client.gui.screen.TitleScreen;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.injection.At;
@@ -10,6 +11,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.info("This line is printed by an example mod mixin!");
 	}
 }