update ConsoleLogger

This commit is contained in:
DNx5 2015-11-03 14:08:51 +07:00
parent e3166c6807
commit 4cbd8aad31

View File

@ -1,5 +1,9 @@
package fr.xephi.authme;
import com.google.common.base.Throwables;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.settings.Settings;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
@ -8,18 +12,12 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Logger;
import com.google.common.base.Throwables;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.settings.Settings;
public class ConsoleLogger {
private static final Logger log = AuthMe.getInstance().getLogger();
private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]");
public static void info(String message) {
if (AuthMe.getInstance().isEnabled()) {
log.info("[AuthMe] " + message);
if (Settings.useLogging) {
String dateTime;
@ -29,10 +27,8 @@ public class ConsoleLogger {
writeLog(dateTime + " " + message);
}
}
}
public static void showError(String message) {
if (AuthMe.getInstance().isEnabled()) {
log.warning("[AuthMe] " + message);
if (Settings.useLogging) {
String dateTime;
@ -42,7 +38,6 @@ public class ConsoleLogger {
writeLog(dateTime + " ERROR: " + message);
}
}
}
public static void writeLog(String message) {
try {
@ -54,10 +49,12 @@ public class ConsoleLogger {
}
public static void writeStackTrace(Exception ex) {
if (Settings.useLogging) {
String dateTime;
synchronized (df) {
dateTime = df.format(new Date());
}
writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex));
}
}
}