Add event logging
This commit is contained in:
parent
00268e4307
commit
acbfd6b189
1 changed files with 14 additions and 0 deletions
|
@ -21,6 +21,8 @@ package de.staropensource.sosengine.base.classes.helpers;
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.annotations.EventListener;
|
import de.staropensource.sosengine.base.annotations.EventListener;
|
||||||
import de.staropensource.sosengine.base.classes.Event;
|
import de.staropensource.sosengine.base.classes.Event;
|
||||||
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
|
import de.staropensource.sosengine.base.types.LogIssuer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
@ -45,6 +47,16 @@ public class EventHelper {
|
||||||
*/
|
*/
|
||||||
public EventHelper() {}
|
public EventHelper() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the event call.
|
||||||
|
*
|
||||||
|
* @param clazz event class
|
||||||
|
* @since 1-alpha0
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static void logCall(Class<? extends Event> clazz) {
|
||||||
|
Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all annotated methods.
|
* Returns all annotated methods.
|
||||||
|
@ -81,6 +93,8 @@ public class EventHelper {
|
||||||
* @since 1-alpha0
|
* @since 1-alpha0
|
||||||
*/
|
*/
|
||||||
public static void invokeAnnotatedMethods(Class<? extends Event> clazz) {
|
public static void invokeAnnotatedMethods(Class<? extends Event> clazz) {
|
||||||
|
logCall(clazz);
|
||||||
|
|
||||||
for (Method method : getAnnotatedMethods(clazz)) {
|
for (Method method : getAnnotatedMethods(clazz)) {
|
||||||
try {
|
try {
|
||||||
method.invoke(null);
|
method.invoke(null);
|
||||||
|
|
Loading…
Reference in a new issue