* #1874 Introduce individual ConsoleLogger instance per class - Create ConsoleLoggerFactory from which a separate logger can be created for each class - Allows to support individual log level settings in the future * Fix CodeStyle issue * Replace full class name with import * Update usages after merge from master
This commit is contained in:
+6
-13
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSourceType;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -18,8 +19,10 @@ import static fr.xephi.authme.util.Utils.logAndSendMessage;
|
||||
*/
|
||||
public abstract class AbstractDataSourceConverter<S extends DataSource> implements Converter {
|
||||
|
||||
private DataSource destination;
|
||||
private DataSourceType destinationType;
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(MySqlToSqlite.class);
|
||||
|
||||
private final DataSource destination;
|
||||
private final DataSourceType destinationType;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -51,7 +54,7 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
|
||||
source = getSource();
|
||||
} catch (Exception e) {
|
||||
logAndSendMessage(sender, "The data source to convert from could not be initialized");
|
||||
ConsoleLogger.logException("Could not initialize source:", e);
|
||||
logger.logException("Could not initialize source:", e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +63,6 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
|
||||
if (destination.isAuthAvailable(auth.getNickname())) {
|
||||
skippedPlayers.add(auth.getNickname());
|
||||
} else {
|
||||
adaptPlayerAuth(auth);
|
||||
destination.saveAuth(auth);
|
||||
destination.updateSession(auth);
|
||||
destination.updateQuitLoc(auth);
|
||||
@@ -75,15 +77,6 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
|
||||
+ " to " + destinationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts the PlayerAuth from the source before it is saved in the destination.
|
||||
*
|
||||
* @param auth the auth from the source
|
||||
*/
|
||||
protected void adaptPlayerAuth(PlayerAuth auth) {
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data source to convert from
|
||||
* @throws Exception during initialization of source
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.ConverterSettings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -19,6 +20,8 @@ import java.io.IOException;
|
||||
*/
|
||||
public class CrazyLoginConverter implements Converter {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(CrazyLoginConverter.class);
|
||||
|
||||
private final DataSource database;
|
||||
private final Settings settings;
|
||||
private final File dataFolder;
|
||||
@@ -46,10 +49,10 @@ public class CrazyLoginConverter implements Converter {
|
||||
migrateAccount(line);
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("CrazyLogin database has been imported correctly");
|
||||
logger.info("CrazyLogin database has been imported correctly");
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.warning("Can't open the crazylogin database file! Does it exist?");
|
||||
ConsoleLogger.logException("Encountered", ex);
|
||||
logger.warning("Can't open the crazylogin database file! Does it exist?");
|
||||
logger.logException("Encountered", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.ConverterSettings;
|
||||
import fr.xephi.authme.util.UuidUtils;
|
||||
@@ -31,6 +32,7 @@ import static fr.xephi.authme.util.Utils.logAndSendMessage;
|
||||
*/
|
||||
public class LoginSecurityConverter implements Converter {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(LoginSecurityConverter.class);
|
||||
private final File dataFolder;
|
||||
private final DataSource dataSource;
|
||||
|
||||
@@ -60,7 +62,7 @@ public class LoginSecurityConverter implements Converter {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
sender.sendMessage("Failed to convert from SQLite. Please see the log for more info");
|
||||
ConsoleLogger.logException("Could not fetch or migrate data:", e);
|
||||
logger.logException("Could not fetch or migrate data:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +191,7 @@ public class LoginSecurityConverter implements Converter {
|
||||
return DriverManager.getConnection(
|
||||
"jdbc:sqlite:" + path, "trump", "donald");
|
||||
} catch (SQLException e) {
|
||||
ConsoleLogger.logException("Could not connect to SQLite database", e);
|
||||
logger.logException("Could not connect to SQLite database", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +201,7 @@ public class LoginSecurityConverter implements Converter {
|
||||
return DriverManager.getConnection(
|
||||
"jdbc:mysql://" + mySqlHost + "/" + mySqlDatabase, mySqlUser, mySqlPassword);
|
||||
} catch (SQLException e) {
|
||||
ConsoleLogger.logException("Could not connect to SQLite database", e);
|
||||
logger.logException("Could not connect to SQLite database", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@@ -25,6 +26,7 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
public class RakamakConverter implements Converter {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(RakamakConverter.class);
|
||||
private final DataSource database;
|
||||
private final Settings settings;
|
||||
private final File pluginFolder;
|
||||
@@ -88,7 +90,7 @@ public class RakamakConverter implements Converter {
|
||||
}
|
||||
Utils.logAndSendMessage(sender, "Rakamak database has been imported successfully");
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.logException("Can't open the rakamak database file! Does it exist?", ex);
|
||||
logger.logException("Can't open the rakamak database file! Does it exist?", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -18,6 +19,9 @@ public class RoyalAuthConverter implements Converter {
|
||||
|
||||
private static final String LAST_LOGIN_PATH = "timestamps.quit";
|
||||
private static final String PASSWORD_PATH = "login.password";
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(RoyalAuthConverter.class);
|
||||
|
||||
private final AuthMe plugin;
|
||||
private final DataSource dataSource;
|
||||
|
||||
@@ -48,7 +52,7 @@ public class RoyalAuthConverter implements Converter {
|
||||
dataSource.saveAuth(auth);
|
||||
dataSource.updateSession(auth);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e);
|
||||
logger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,6 +19,7 @@ import static fr.xephi.authme.util.FileUtils.makePath;
|
||||
|
||||
public class VAuthConverter implements Converter {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(VAuthConverter.class);
|
||||
private final DataSource dataSource;
|
||||
private final File vAuthPasswordsFile;
|
||||
|
||||
@@ -58,7 +60,7 @@ public class VAuthConverter implements Converter {
|
||||
dataSource.saveAuth(auth);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ConsoleLogger.logException("Error while trying to import some vAuth data", e);
|
||||
logger.logException("Error while trying to import some vAuth data", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user