#605 Add custom log levels, create debug logging method
- Log levels in the log file too - Create migration from old boolean "stop spam" property to new log level property
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.LogLevel;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.propertymap.PropertyMap;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
@@ -48,7 +50,8 @@ public class SettingsMigrationService {
|
||||
return changes
|
||||
| performMailTextToFileMigration(configuration, pluginFolder)
|
||||
| migrateJoinLeaveMessages(configuration)
|
||||
| migrateForceSpawnSettings(configuration);
|
||||
| migrateForceSpawnSettings(configuration)
|
||||
| changeBooleanSettingToLogLevelProperty(configuration);
|
||||
}
|
||||
|
||||
public boolean containsAllSettings(FileConfiguration configuration, PropertyMap propertyMap) {
|
||||
@@ -141,6 +144,25 @@ public class SettingsMigrationService {
|
||||
| moveProperty(oldForceWorlds, FORCE_SPAWN_ON_WORLDS, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the old boolean property "hide spam from console" to the new property specifying
|
||||
* the log level.
|
||||
*
|
||||
* @param configuration The file configuration
|
||||
* @return True if the configuration has changed, false otherwise
|
||||
*/
|
||||
private static boolean changeBooleanSettingToLogLevelProperty(FileConfiguration configuration) {
|
||||
final String oldPath = "Security.console.noConsoleSpam";
|
||||
final Property<LogLevel> newProperty = PluginSettings.LOG_LEVEL;
|
||||
if (!newProperty.isPresent(configuration) && configuration.contains(oldPath)) {
|
||||
ConsoleLogger.info("Moving '" + oldPath + "' to '" + newProperty.getPath() + "'");
|
||||
LogLevel level = configuration.getBoolean(oldPath) ? LogLevel.INFO : LogLevel.FINE;
|
||||
configuration.set(newProperty.getPath(), level.name());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for an old property path and moves it to a new path if present.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.settings.properties;
|
||||
|
||||
import fr.xephi.authme.output.LogLevel;
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
@@ -59,6 +60,14 @@ public class PluginSettings implements SettingsClass {
|
||||
public static final Property<Boolean> KEEP_COLLISIONS_DISABLED =
|
||||
newProperty("settings.restrictions.keepCollisionsDisabled", false);
|
||||
|
||||
@Comment({
|
||||
"Log level: INFO, FINE, DEBUG. Use INFO for general messages,",
|
||||
"FINE for some additional detailed ones (like password failed),",
|
||||
"and DEBUG for debugging"
|
||||
})
|
||||
public static final Property<LogLevel> LOG_LEVEL =
|
||||
newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE);
|
||||
|
||||
private PluginSettings() {
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@ public class SecuritySettings implements SettingsClass {
|
||||
public static final Property<Boolean> USE_RELOAD_COMMAND_SUPPORT =
|
||||
newProperty("Security.ReloadCommand.useReloadCommandSupport", true);
|
||||
|
||||
@Comment("Remove spam from console?")
|
||||
public static final Property<Boolean> REMOVE_SPAM_FROM_CONSOLE =
|
||||
newProperty("Security.console.noConsoleSpam", false);
|
||||
|
||||
@Comment("Remove passwords from console?")
|
||||
public static final Property<Boolean> REMOVE_PASSWORD_FROM_CONSOLE =
|
||||
newProperty("Security.console.removePassword", true);
|
||||
|
||||
Reference in New Issue
Block a user