diff options
author | Luck <git@lucko.me> | 2021-11-01 20:45:46 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2021-11-01 20:46:16 +0000 |
commit | fe578229bf7e77b522eda8737374c2f26b30c24b (patch) | |
tree | 467b78fbbccb801788194f6a6e586963458f41d8 /spark-sponge/src | |
parent | 8ebf2d39a1d95c409d2151374b8ff1ad9e776d97 (diff) | |
download | spark-fe578229bf7e77b522eda8737374c2f26b30c24b.tar.gz spark-fe578229bf7e77b522eda8737374c2f26b30c24b.tar.bz2 spark-fe578229bf7e77b522eda8737374c2f26b30c24b.zip |
async-profiler on macos
Diffstat (limited to 'spark-sponge/src')
-rw-r--r-- | spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java | 19 |
1 files changed, 18 insertions, 1 deletions
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; @@ -123,6 +127,19 @@ public class SpongeSparkPlugin implements SparkPlugin { } @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(); } |