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/velocity/VelocitySparkPlugin.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'spark-velocity/src/main/java/me') diff --git a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java index 40c470f..698aab0 100644 --- a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java +++ b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java @@ -35,8 +35,11 @@ import me.lucko.spark.common.SparkPlugin; import me.lucko.spark.common.platform.PlatformInfo; import me.lucko.spark.common.util.ClassSourceLookup; +import org.slf4j.Logger; + import java.nio.file.Path; import java.util.List; +import java.util.logging.Level; import java.util.stream.Stream; @Plugin( @@ -49,13 +52,15 @@ import java.util.stream.Stream; public class VelocitySparkPlugin implements SparkPlugin, SimpleCommand { private final ProxyServer proxy; + private final Logger logger; private final Path configDirectory; private SparkPlatform platform; @Inject - public VelocitySparkPlugin(ProxyServer proxy, @DataDirectory Path configDirectory) { + public VelocitySparkPlugin(ProxyServer proxy, Logger logger, @DataDirectory Path configDirectory) { this.proxy = proxy; + this.logger = logger; this.configDirectory = configDirectory; } @@ -109,6 +114,19 @@ public class VelocitySparkPlugin implements SparkPlugin, SimpleCommand { this.proxy.getScheduler().buildTask(this, task).schedule(); } + @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 ClassSourceLookup createClassSourceLookup() { return new VelocityClassSourceLookup(this.proxy.getPluginManager()); -- cgit