Fixed logging

This commit is contained in:
2022-08-07 20:30:13 +02:00
parent 5784be50b3
commit c023531e85
3 changed files with 22 additions and 12 deletions
@@ -1,32 +1,43 @@
package com.alttd.boosterapi.util;
import org.apache.commons.lang.exception.ExceptionUtils;
import java.util.logging.Logger;
public class ALogger {
private static org.slf4j.Logger logger;
private static org.slf4j.Logger velocityLogger = null;
private static Logger bukkitLogger = null;
public static void init(org.slf4j.Logger log) {
logger = log;
velocityLogger = log;
}
private void log(String message) {
logger.info(message);
public static void init(Logger log) {
bukkitLogger = log;
}
public static void warn(String message) {
logger.warn(message);
if (velocityLogger != null)
velocityLogger.warn(message);
if (bukkitLogger != null)
bukkitLogger.warning(message);
}
public static void info(String message) {
logger.info(message);
if (velocityLogger != null)
velocityLogger.info(message);
if (bukkitLogger != null)
bukkitLogger.info(message);
}
public static void error(String message) {
logger.error(message);
if (velocityLogger != null)
velocityLogger.error(message);
if (bukkitLogger != null)
bukkitLogger.severe(message);
}
public static void fatal(String error, Exception exception) {
logger.error(error + "\n" + ExceptionUtils.getStackTrace(exception));
error(error + "\n" + ExceptionUtils.getStackTrace(exception));
}
}