2022-07-20 13:18:57 +02:00
|
|
|
package fr.pandacube.lib.util;
|
2016-07-12 19:26:49 +02:00
|
|
|
|
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;
|
|
|
|
|
2022-07-20 13:18:57 +02:00
|
|
|
public final class Log {
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2022-02-07 12:39:48 +01:00
|
|
|
private static Logger logger = Logger.getGlobal();
|
2022-07-10 00:55:56 +02:00
|
|
|
private static final AtomicBoolean logDebug = new AtomicBoolean(false);
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2021-07-25 20:14:06 +02:00
|
|
|
public static void setDebug(boolean newVal) {
|
2016-07-14 01:46:44 +02:00
|
|
|
logDebug.set(newVal);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2021-07-25 20:14:06 +02:00
|
|
|
public static boolean isDebugEnabled() {
|
2016-07-14 01:46:44 +02:00
|
|
|
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;
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void info(String message) {
|
|
|
|
logger.info(message);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void warning(String message, Throwable t) {
|
|
|
|
logger.log(Level.WARNING, message, t);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void warning(Throwable t) {
|
|
|
|
logger.log(Level.WARNING, "", t);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void warning(String message) {
|
|
|
|
logger.warning(message);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void severe(String message, Throwable t) {
|
|
|
|
logger.log(Level.SEVERE, message, t);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void severe(Throwable t) {
|
|
|
|
logger.log(Level.SEVERE, "", t);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-12 19:26:49 +02:00
|
|
|
public static void severe(String message) {
|
|
|
|
logger.severe(message);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
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);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-14 01:46:44 +02:00
|
|
|
public static void debug(Throwable t) {
|
|
|
|
if (!logDebug.get()) return;
|
|
|
|
logger.log(Level.INFO, "", t);
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-14 01:46:44 +02:00
|
|
|
public static void debug(String message) {
|
|
|
|
if (!logDebug.get()) return;
|
|
|
|
logger.info(message);
|
|
|
|
}
|
2016-07-12 19:26:49 +02:00
|
|
|
|
|
|
|
}
|