#605 Logger - name methods after their log level

- Remove separate print stacktrace method
- Log level into the log similar to console output
This commit is contained in:
ljacqu
2016-07-12 22:05:36 +02:00
parent dccbd5262f
commit e7b980d435
32 changed files with 79 additions and 89 deletions
@@ -190,7 +190,7 @@ public class BukkitService {
return Arrays.asList((Player[]) obj);
} else {
String type = (obj == null) ? "null" : obj.getClass().getName();
ConsoleLogger.showError("Unknown list of online players of type " + type);
ConsoleLogger.warning("Unknown list of online players of type " + type);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
ConsoleLogger.logException("Could not retrieve list of online players:", e);
@@ -230,7 +230,7 @@ public class BukkitService {
Method method = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
return method.getReturnType() == Collection.class;
} catch (NoSuchMethodException e) {
ConsoleLogger.showError("Error verifying if getOnlinePlayers is a collection! Method doesn't exist");
ConsoleLogger.warning("Error verifying if getOnlinePlayers is a collection! Method doesn't exist");
}
return false;
}
@@ -30,7 +30,7 @@ public class FileUtils {
if (destinationFile.exists()) {
return true;
} else if (!destinationFile.getParentFile().exists() && !destinationFile.getParentFile().mkdirs()) {
ConsoleLogger.showError("Cannot create parent directories for '" + destinationFile + "'");
ConsoleLogger.warning("Cannot create parent directories for '" + destinationFile + "'");
return false;
}
@@ -38,7 +38,7 @@ public class FileUtils {
final String normalizedPath = resourcePath.replace("\\", "/");
try (InputStream is = AuthMe.class.getClassLoader().getResourceAsStream(normalizedPath)) {
if (is == null) {
ConsoleLogger.showError(format("Cannot copy resource '%s' to file '%s': cannot load resource",
ConsoleLogger.warning(format("Cannot copy resource '%s' to file '%s': cannot load resource",
resourcePath, destinationFile.getPath()));
} else {
Files.copy(is, destinationFile.toPath());
@@ -65,7 +65,7 @@ public class GeoLiteAPI {
}
} else {
if (!dataFile.delete()) {
ConsoleLogger.showError("Failed to delete GeoLiteAPI database");
ConsoleLogger.warning("Failed to delete GeoLiteAPI database");
}
}
}
@@ -34,14 +34,14 @@ public final class MigrationService {
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
SHA256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
ConsoleLogger.showError("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
+ " it will be changed and hashed now to the AuthMe default hashing method");
ConsoleLogger.showError("Don't stop your server; wait for the conversion to have been completed!");
ConsoleLogger.warning("Don't stop your server; wait for the conversion to have been completed!");
List<PlayerAuth> allAuths = dataSource.getAllAuths();
for (PlayerAuth auth : allAuths) {
String hash = auth.getPassword().getHash();
if (hash.startsWith("$SHA$")) {
ConsoleLogger.showError("Skipping conversion for " + auth.getNickname() + "; detected SHA hash");
ConsoleLogger.warning("Skipping conversion for " + auth.getNickname() + "; detected SHA hash");
} else {
HashedPassword hashedPassword = authmeSha256.computeHash(hash, auth.getNickname());
auth.setPassword(hashedPassword);
@@ -63,7 +63,7 @@ public final class MigrationService {
*/
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed "
ConsoleLogger.warning("FlatFile backend has been detected and is now deprecated; it will be changed "
+ "to SQLite... Connection will be impossible until conversion is done!");
FlatFile flatFile = (FlatFile) dataSource;
try {
@@ -51,7 +51,7 @@ public final class Utils {
try {
return Pattern.compile(pattern);
} catch (Exception e) {
ConsoleLogger.showError("Failed to compile pattern '" + pattern + "' - defaulting to allowing everything");
ConsoleLogger.warning("Failed to compile pattern '" + pattern + "' - defaulting to allowing everything");
return Pattern.compile(".*?");
}
}