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 --- .../java/me/lucko/spark/sponge/SpongeSparkPlugin.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'spark-sponge/src/main/java/me/lucko/spark') diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java index 5d11c03..45d8d80 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java @@ -29,6 +29,7 @@ import me.lucko.spark.common.platform.PlatformInfo; import me.lucko.spark.common.sampler.ThreadDumper; import me.lucko.spark.common.tick.TickHook; +import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandResult; @@ -49,6 +50,7 @@ import org.spongepowered.api.world.World; import java.nio.file.Path; import java.util.List; import java.util.Optional; +import java.util.logging.Level; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -67,6 +69,7 @@ import javax.annotation.Nullable; public class SpongeSparkPlugin implements SparkPlugin { private final PluginContainer pluginContainer; + private final Logger logger; private final Game game; private final Path configDirectory; private final SpongeExecutorService asyncExecutor; @@ -75,8 +78,9 @@ public class SpongeSparkPlugin implements SparkPlugin { private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread(); @Inject - public SpongeSparkPlugin(PluginContainer pluginContainer, Game game, @ConfigDir(sharedRoot = false) Path configDirectory, @AsynchronousExecutor SpongeExecutorService asyncExecutor) { + public SpongeSparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory, @AsynchronousExecutor SpongeExecutorService asyncExecutor) { this.pluginContainer = pluginContainer; + this.logger = logger; this.game = game; this.configDirectory = configDirectory; this.asyncExecutor = asyncExecutor; @@ -122,6 +126,19 @@ public class SpongeSparkPlugin implements SparkPlugin { this.asyncExecutor.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