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-sponge8/src/main/java/me | |
parent | 8ebf2d39a1d95c409d2151374b8ff1ad9e776d97 (diff) | |
download | spark-fe578229bf7e77b522eda8737374c2f26b30c24b.tar.gz spark-fe578229bf7e77b522eda8737374c2f26b30c24b.tar.bz2 spark-fe578229bf7e77b522eda8737374c2f26b30c24b.zip |
async-profiler on macos
Diffstat (limited to 'spark-sponge8/src/main/java/me')
-rw-r--r-- | spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java index e82fb6d..0195b24 100644 --- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java +++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java @@ -31,6 +31,7 @@ import me.lucko.spark.common.tick.TickHook; import net.kyori.adventure.text.Component; +import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.Game; import org.spongepowered.api.Server; @@ -52,6 +53,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutorService; +import java.util.logging.Level; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -59,6 +61,7 @@ import java.util.stream.Stream; public class Sponge8SparkPlugin implements SparkPlugin { private final PluginContainer pluginContainer; + private final Logger logger; private final Game game; private final Path configDirectory; private final ExecutorService asyncExecutor; @@ -67,8 +70,9 @@ public class Sponge8SparkPlugin implements SparkPlugin { private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread(); @Inject - public Sponge8SparkPlugin(PluginContainer pluginContainer, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) { + public Sponge8SparkPlugin(PluginContainer pluginContainer, Logger logger, Game game, @ConfigDir(sharedRoot = false) Path configDirectory) { this.pluginContainer = pluginContainer; + this.logger = logger; this.game = game; this.configDirectory = configDirectory; this.asyncExecutor = game.asyncScheduler().executor(pluginContainer); @@ -120,6 +124,19 @@ public class Sponge8SparkPlugin 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(); } |