Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
[Fix] Fix Sponge and Velocity logging error
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Oct 13, 2018
1 parent 90c885c commit 747a1f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public SpongePlugin(CombineDebugLogger debugLogger) {
this.debugLogger = debugLogger;
this.runnableFactory = new SpongeRunnableFactory(this);
this.timings = new Timings(debugLogger);
this.logger = new Slf4jPluginLogger(getLogger(), this::getDebugLogger);
this.logger = new Slf4jPluginLogger(this::getLogger, this::getDebugLogger);
this.errorHandler = new DefaultErrorHandler(this, logger, new File(getDataFolder(), "logs"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public VelocityPlugin(CombineDebugLogger debugLogger) {
this.debugLogger = debugLogger;
this.runnableFactory = new VelocityRunnableFactory(this, getProxy().getScheduler());
this.timings = new Timings(debugLogger);
this.logger = new Slf4jPluginLogger(getLogger(), this::getDebugLogger);
this.logger = new Slf4jPluginLogger(this::getLogger, this::getDebugLogger);
this.errorHandler = new DefaultErrorHandler(this, logger, new File(getDataFolder(), "logs"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,27 @@
public class Slf4jPluginLogger implements PluginLogger {

private final Supplier<DebugLogger> debugLogger;
private final Logger logger;
private final Supplier<Logger> loggerSupplier;

/**
* Create a new Slf4jPluginLogger.
*
* @param logger slf4j logger for console logging.
* @param debugLogger Supplier for the {@link DebugLogger} to use.
* @param loggerSupplier slf4j logger for console logging.
* @param debugLogger Supplier for the {@link DebugLogger} to use.
*/
public Slf4jPluginLogger(Logger logger, Supplier<DebugLogger> debugLogger) {
public Slf4jPluginLogger(Logger loggerSupplier, Supplier<DebugLogger> debugLogger) {
this(() -> loggerSupplier, debugLogger);
}

/**
* Create a new Slf4jPluginLogger
*
* @param loggerSupplier slf4j logger for console logging.
* @param debugLogger Supplier for the {@link DebugLogger} to use.
*/
public Slf4jPluginLogger(Supplier<Logger> loggerSupplier, Supplier<DebugLogger> debugLogger) {
this.debugLogger = debugLogger;
this.logger = logger;
this.loggerSupplier = loggerSupplier;
}

@Override
Expand All @@ -35,6 +45,7 @@ public void log(L level, String... message) {
} else if (level != L.DEBUG_INFO) {
log(L.DEBUG, message);
}
Logger logger = loggerSupplier.get();
switch (level) {
case CRITICAL:
case ERROR:
Expand Down Expand Up @@ -64,6 +75,7 @@ public void log(L level, String... message) {

@Override
public void log(L level, String message, Throwable throwable) {
Logger logger = loggerSupplier.get();
switch (level) {
case CRITICAL:
case ERROR:
Expand Down

0 comments on commit 747a1f4

Please sign in to comment.