From fe578229bf7e77b522eda8737374c2f26b30c24b Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 1 Nov 2021 20:45:46 +0000 Subject: async-profiler on macos --- .../me/lucko/spark/forge/plugin/ForgeSparkPlugin.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spark-forge/src/main') diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java index e4e73dd..f8b7559 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java @@ -40,10 +40,14 @@ import me.lucko.spark.forge.ForgeSparkMod; import net.minecraft.commands.CommandSource; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.nio.file.Path; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.logging.Level; public abstract class ForgeSparkPlugin implements SparkPlugin { @@ -67,12 +71,14 @@ public abstract class ForgeSparkPlugin implements SparkPlugin { } private final ForgeSparkMod mod; + private final Logger logger; protected final ScheduledExecutorService scheduler; protected final SparkPlatform platform; protected final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread(); protected ForgeSparkPlugin(ForgeSparkMod mod) { this.mod = mod; + this.logger = LogManager.getLogger("spark"); this.scheduler = Executors.newSingleThreadScheduledExecutor(r -> { Thread thread = Executors.defaultThreadFactory().newThread(r); thread.setName("spark-forge-async-worker"); @@ -108,6 +114,19 @@ public abstract class ForgeSparkPlugin implements SparkPlugin { this.scheduler.execute(task); } + @Override + public void log(Level level, String msg) { + if (level == Level.INFO) { + this.logger.info(msg); + } else if (level == Level.WARNING) { + this.logger.warn(msg); + } else if (level == Level.SEVERE) { + this.logger.error(msg); + } else { + throw new IllegalArgumentException(level.getName()); + } + } + @Override public ThreadDumper getDefaultThreadDumper() { return this.threadDumper.get(); -- cgit