diff --git a/lib/src/main/java/net/tomatentum/marinara/checks/AppliedCheck.java b/lib/src/main/java/net/tomatentum/marinara/checks/AppliedCheck.java index 0383ac6..6f7ec53 100644 --- a/lib/src/main/java/net/tomatentum/marinara/checks/AppliedCheck.java +++ b/lib/src/main/java/net/tomatentum/marinara/checks/AppliedCheck.java @@ -5,9 +5,14 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; +import org.apache.logging.log4j.Logger; + +import net.tomatentum.marinara.util.LoggerUtil; import net.tomatentum.marinara.util.ReflectionUtil; public record AppliedCheck(InteractionCheck check, Annotation annotation) { + + private static Logger logger = LoggerUtil.getLogger(AppliedCheck.class); public boolean pre(Object context) { Method[] methods = Arrays.stream(check.getClass().getMethods()) @@ -17,9 +22,10 @@ public record AppliedCheck(InteractionCheck check, Annotation annotation) { Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass(), annotation.annotationType()); method.setAccessible(true); try { + logger.debug("Executing pre check {} with context {}", check.getClass().getName(), context.toString()); return (boolean) method.invoke(check, context, annotation); } catch (IllegalAccessException | InvocationTargetException | SecurityException e) { - e.printStackTrace(); + logger.fatal(e); return false; } } @@ -32,9 +38,10 @@ public record AppliedCheck(InteractionCheck check, Annotation annotation) { Method method = ReflectionUtil.getMostSpecificMethod(methods, context.getClass(), annotation.annotationType()); method.setAccessible(true); try { + logger.debug("Executing pre check {} with context {}", check.getClass().getName(), context.toString()); method.invoke(check, context, annotation); } catch (IllegalAccessException | InvocationTargetException | SecurityException e) { - e.printStackTrace(); + logger.fatal(e); } } diff --git a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java index 370419e..59f5220 100644 --- a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java +++ b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java @@ -6,19 +6,25 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import org.apache.logging.log4j.Logger; + import io.leangen.geantyref.GenericTypeReflector; import net.tomatentum.marinara.checks.InteractionCheck; +import net.tomatentum.marinara.util.LoggerUtil; public class InteractionCheckRegistry { private List> checks; + private Logger logger = LoggerUtil.getLogger(getClass()); + public InteractionCheckRegistry() { this.checks = new ArrayList<>(); } public void addCheck(InteractionCheck check) { checks.add(check); + logger.info("Registered Check {}", check.getClass().getName()); } public Optional> getCheckFromAnnotation(Type annotation) {