#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
@@ -160,7 +160,7 @@ public class CacheDataSource implements DataSource {
try {
executorService.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.logException("Could not close executor service:", e);
}
}
@@ -50,7 +50,7 @@ public class FlatFile implements DataSource {
} catch (IOException e) {
ConsoleLogger.logException("Cannot open flatfile", e);
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
ConsoleLogger.warning("Can't use FLAT FILE... SHUTDOWN...");
instance.getServer().shutdown();
}
if (!Settings.isStopEnabled) {
@@ -82,7 +82,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(br);
@@ -109,7 +109,7 @@ public class FlatFile implements DataSource {
bw = new BufferedWriter(new FileWriter(source, true));
bw.write(auth.getNickname() + ":" + auth.getPassword().getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(bw);
@@ -145,7 +145,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(br);
@@ -179,7 +179,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(br);
@@ -216,7 +216,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(br);
@@ -246,7 +246,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return list;
} finally {
silentClose(br);
@@ -279,7 +279,7 @@ public class FlatFile implements DataSource {
bw.write(l + "\n");
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return;
} finally {
silentClose(br);
@@ -309,7 +309,7 @@ public class FlatFile implements DataSource {
bw.write(l + "\n");
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
silentClose(br);
@@ -331,7 +331,7 @@ public class FlatFile implements DataSource {
}
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return null;
} finally {
silentClose(br);
@@ -364,10 +364,10 @@ public class FlatFile implements DataSource {
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
if (br != null) {
@@ -399,10 +399,10 @@ public class FlatFile implements DataSource {
}
return countIp;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return new ArrayList<>();
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return new ArrayList<>();
} finally {
if (br != null) {
@@ -429,7 +429,7 @@ public class FlatFile implements DataSource {
}
return countEmail;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
} finally {
if (br != null) {
try {
@@ -473,7 +473,7 @@ public class FlatFile implements DataSource {
result++;
}
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return result;
} finally {
silentClose(br);
@@ -52,14 +52,14 @@ public class MySQL implements DataSource {
this.setConnectionArguments();
} catch (RuntimeException e) {
if (e instanceof IllegalArgumentException) {
ConsoleLogger.showError("Invalid database arguments! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer!");
ConsoleLogger.warning("Invalid database arguments! Please check your configuration!");
ConsoleLogger.warning("If this error persists, please report it to the developer!");
}
if (e instanceof PoolInitializationException) {
ConsoleLogger.showError("Can't initialize database connection! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer!");
ConsoleLogger.warning("Can't initialize database connection! Please check your configuration!");
ConsoleLogger.warning("If this error persists, please report it to the developer!");
}
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer!");
ConsoleLogger.warning("Can't use the Hikari Connection Pool! Please, report this error to the developer!");
throw e;
}
@@ -69,7 +69,7 @@ public class MySQL implements DataSource {
} catch (SQLException e) {
close();
ConsoleLogger.logException("Can't initialize the MySQL database:", e);
ConsoleLogger.showError("Please check your database settings in the config.yml file!");
ConsoleLogger.warning("Please check your database settings in the config.yml file!");
throw e;
}
}
@@ -879,7 +879,7 @@ public class MySQL implements DataSource {
final int columnType;
try (ResultSet rs = metaData.getColumns(null, null, tableName, col.LAST_LOGIN)) {
if (!rs.next()) {
ConsoleLogger.showError("Could not get LAST_LOGIN meta data. This should never happen!");
ConsoleLogger.warning("Could not get LAST_LOGIN meta data. This should never happen!");
return;
}
columnType = rs.getInt("DATA_TYPE");
@@ -157,7 +157,7 @@ public class SQLite implements DataSource {
rs = pst.executeQuery();
return rs.next();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.warning(ex.getMessage());
return false;
} finally {
close(rs);
@@ -212,7 +212,7 @@ public class SQLite implements DataSource {
HashedPassword password = auth.getPassword();
if (col.SALT.isEmpty()) {
if (!StringUtils.isEmpty(auth.getPassword().getSalt())) {
ConsoleLogger.showError("Warning! Detected hashed password with separate salt but the salt column "
ConsoleLogger.warning("Warning! Detected hashed password with separate salt but the salt column "
+ "is not set in the config!");
}
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + col.NAME + "," + col.PASSWORD +