#1874 Introduce individual ConsoleLogger instance per class (#1875)

* #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:
ljacqu
2019-08-06 15:15:16 +02:00
committed by Gabriele C
parent 254d4d75a2
commit c34f00f759
98 changed files with 853 additions and 387 deletions
@@ -8,6 +8,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.columnshandler.AuthMeColumnsHandler;
import fr.xephi.authme.datasource.mysqlextensions.MySqlExtension;
import fr.xephi.authme.datasource.mysqlextensions.MySqlExtensionsFactory;
import fr.xephi.authme.output.ConsoleLoggerFactory;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
@@ -34,6 +35,7 @@ import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
*/
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore
public class MySQL extends AbstractSqlDataSource {
private final ConsoleLogger logger = ConsoleLoggerFactory.get(MySQL.class);
private boolean useSsl;
private boolean serverCertificateVerification;
@@ -58,14 +60,14 @@ public class MySQL extends AbstractSqlDataSource {
this.setConnectionArguments();
} catch (RuntimeException e) {
if (e instanceof IllegalArgumentException) {
ConsoleLogger.warning("Invalid database arguments! Please check your configuration!");
ConsoleLogger.warning("If this error persists, please report it to the developer!");
logger.warning("Invalid database arguments! Please check your configuration!");
logger.warning("If this error persists, please report it to the developer!");
}
if (e instanceof PoolInitializationException) {
ConsoleLogger.warning("Can't initialize database connection! Please check your configuration!");
ConsoleLogger.warning("If this error persists, please report it to the developer!");
logger.warning("Can't initialize database connection! Please check your configuration!");
logger.warning("If this error persists, please report it to the developer!");
}
ConsoleLogger.warning("Can't use the Hikari Connection Pool! Please, report this error to the developer!");
logger.warning("Can't use the Hikari Connection Pool! Please, report this error to the developer!");
throw e;
}
@@ -74,8 +76,8 @@ public class MySQL extends AbstractSqlDataSource {
checkTablesAndColumns();
} catch (SQLException e) {
closeConnection();
ConsoleLogger.logException("Can't initialize the MySQL database:", e);
ConsoleLogger.warning("Please check your database settings in the config.yml file!");
logger.logException("Can't initialize the MySQL database:", e);
logger.warning("Please check your database settings in the config.yml file!");
throw e;
}
}
@@ -149,7 +151,7 @@ public class MySQL extends AbstractSqlDataSource {
ds.addDataSourceProperty("prepStmtCacheSize", "275");
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
logger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
}
@Override
@@ -158,7 +160,7 @@ public class MySQL extends AbstractSqlDataSource {
ds.close();
}
setConnectionArguments();
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
logger.info("Hikari ConnectionPool arguments reloaded!");
}
private Connection getConnection() throws SQLException {
@@ -272,7 +274,7 @@ public class MySQL extends AbstractSqlDataSource {
+ " ADD COLUMN " + col.PLAYER_UUID + " VARCHAR(36)");
}
}
ConsoleLogger.info("MySQL setup finished");
logger.info("MySQL setup finished");
}
private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException {