mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-03-12 22:59:14 +01:00
Fix a few issues with debug logging
Also add a warning if the updater section is missing
This commit is contained in:
parent
cc362a1b7f
commit
402390866a
@ -157,6 +157,9 @@ public class ProtocolConfig {
|
||||
}
|
||||
if (global != null) {
|
||||
updater = global.getConfigurationSection(SECTION_AUTOUPDATER);
|
||||
if (updater.getValues(true).isEmpty()) {
|
||||
plugin.getLogger().warning("Updater section is missing, regenerate your config!");
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically copy defaults
|
||||
|
@ -71,7 +71,6 @@ public class ProtocolLibrary {
|
||||
ProtocolLibrary.reporter = reporter;
|
||||
ProtocolLibrary.executorAsync = executorAsync;
|
||||
ProtocolLibrary.executorSync = executorSync;
|
||||
ProtocolLogger.init(plugin);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ package com.comphenix.protocol;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -26,17 +25,17 @@ import org.bukkit.plugin.Plugin;
|
||||
* @author dmulloy2
|
||||
*/
|
||||
public class ProtocolLogger {
|
||||
private static Logger logger;
|
||||
private static Plugin plugin;
|
||||
|
||||
protected static void init(Plugin plugin) {
|
||||
ProtocolLogger.logger = plugin.getLogger();
|
||||
ProtocolLogger.plugin = plugin;
|
||||
}
|
||||
|
||||
private static boolean isDebugEnabled() {
|
||||
try {
|
||||
return ProtocolLibrary.getConfig().isDebug();
|
||||
} catch (Throwable ex) {
|
||||
return true; // For testing
|
||||
return plugin.getConfig().getBoolean("global.debug", false);
|
||||
} catch (Throwable ex) { // Maybe we're testing or something
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ public class ProtocolLogger {
|
||||
* @param args Arguments to format in
|
||||
*/
|
||||
public static void log(Level level, String message, Object... args) {
|
||||
logger.log(level, MessageFormat.format(message, args));
|
||||
plugin.getLogger().log(level, MessageFormat.format(message, args));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,16 +65,12 @@ public class ProtocolLogger {
|
||||
* @param ex Exception to log
|
||||
*/
|
||||
public static void log(Level level, String message, Throwable ex) {
|
||||
logger.log(level, message, ex);
|
||||
plugin.getLogger().log(level, message, ex);
|
||||
}
|
||||
|
||||
public static void debug(String message, Object... args) {
|
||||
if (isDebugEnabled()) {
|
||||
if (logger != null) {
|
||||
log("[Debug] " + message, args);
|
||||
} else {
|
||||
System.out.println("[Debug] " + MessageFormat.format(message, args));
|
||||
}
|
||||
log("[Debug] " + message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,8 +148,10 @@ public class ProtocolLib extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Load configuration
|
||||
// Logging
|
||||
logger = getLoggerSafely();
|
||||
ProtocolLogger.init(this);
|
||||
|
||||
Application.registerPrimaryThread();
|
||||
|
||||
// Initialize enhancer factory
|
||||
|
Loading…
Reference in New Issue
Block a user