From 4cbd8aad31648c519308a1cea6a424edbb8cbc06 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 3 Nov 2015 14:08:51 +0700 Subject: [PATCH] update ConsoleLogger --- .../java/fr/xephi/authme/ConsoleLogger.java | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/main/java/fr/xephi/authme/ConsoleLogger.java b/src/main/java/fr/xephi/authme/ConsoleLogger.java index b7e757905..e791e352e 100644 --- a/src/main/java/fr/xephi/authme/ConsoleLogger.java +++ b/src/main/java/fr/xephi/authme/ConsoleLogger.java @@ -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,39 +12,30 @@ 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; - synchronized (df) { - dateTime = df.format(new Date()); - } - writeLog(dateTime + " " + message); + log.info("[AuthMe] " + message); + if (Settings.useLogging) { + String dateTime; + synchronized (df) { + dateTime = df.format(new Date()); } + writeLog(dateTime + " " + message); } } public static void showError(String message) { - if (AuthMe.getInstance().isEnabled()) { - log.warning("[AuthMe] " + message); - if (Settings.useLogging) { - String dateTime; - synchronized (df) { - dateTime = df.format(new Date()); - } - writeLog(dateTime + " ERROR: " + message); + log.warning("[AuthMe] " + message); + if (Settings.useLogging) { + String dateTime; + synchronized (df) { + dateTime = df.format(new Date()); } + writeLog(dateTime + " ERROR: " + message); } } @@ -54,10 +49,12 @@ public class ConsoleLogger { } public static void writeStackTrace(Exception ex) { - String dateTime; - synchronized (df) { - dateTime = df.format(new Date()); + if (Settings.useLogging) { + String dateTime; + synchronized (df) { + dateTime = df.format(new Date()); + } + writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex)); } - writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex)); } }