2016-07-12 19:26:49 +02:00
|
|
|
package fr.pandacube.java.util;
|
|
|
|
|
2016-07-14 01:46:44 +02:00
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
2016-07-12 19:26:49 +02:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
public class Log {
|
|
|
|
|
|
|
|
private static Logger logger;
|
2016-07-14 01:46:44 +02:00
|
|
|
private static AtomicBoolean logDebug = new AtomicBoolean(false);
|
|
|
|
|
|
|
|
public static void setDebugState(boolean newVal) {
|
|
|
|
logDebug.set(newVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean getDebugState() {
|
|
|
|
return logDebug.get();
|
|
|
|
}
|
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
|
|
|
|
public static Logger getLogger() {
|
|
|
|
return logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setLogger(Logger l) {
|
|
|
|
logger = l;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void info(String message) {
|
|
|
|
logger.info(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void warning(String message, Throwable t) {
|
|
|
|
logger.log(Level.WARNING, message, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void warning(Throwable t) {
|
|
|
|
logger.log(Level.WARNING, "", t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void warning(String message) {
|
|
|
|
logger.warning(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void severe(String message, Throwable t) {
|
|
|
|
logger.log(Level.SEVERE, message, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void severe(Throwable t) {
|
|
|
|
logger.log(Level.SEVERE, "", t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void severe(String message) {
|
|
|
|
logger.severe(message);
|
|
|
|
}
|
2016-07-14 01:46:44 +02:00
|
|
|
|
|
|
|
public static void debug(String message, Throwable t) {
|
|
|
|
if (!logDebug.get()) return;
|
|
|
|
logger.log(Level.INFO, message, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void debug(Throwable t) {
|
|
|
|
if (!logDebug.get()) return;
|
|
|
|
logger.log(Level.INFO, "", t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void debug(String message) {
|
|
|
|
if (!logDebug.get()) return;
|
|
|
|
logger.info(message);
|
|
|
|
}
|
2016-07-12 19:26:49 +02:00
|
|
|
|
|
|
|
}
|