Inline EventHelper#logCall
This commit is contained in:
parent
54b7b9a695
commit
c473c27298
2 changed files with 6 additions and 21 deletions
|
@ -19,9 +19,8 @@
|
|||
|
||||
package de.staropensource.sosengine.base;
|
||||
|
||||
import de.staropensource.sosengine.base.implementable.ShortcodeParser;
|
||||
import de.staropensource.sosengine.base.implementable.Configuration;
|
||||
import de.staropensource.sosengine.base.implementable.helper.EventHelper;
|
||||
import de.staropensource.sosengine.base.implementable.ShortcodeParser;
|
||||
import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.logging.LoggingThread;
|
||||
|
@ -95,7 +94,6 @@ public final class EngineConfiguration extends Configuration {
|
|||
/**
|
||||
* If enabled, all called events will be logged.
|
||||
*
|
||||
* @see EventHelper#logCall(Class, Object...)
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #debugEvents}.
|
||||
|
|
|
@ -76,22 +76,6 @@ public final class EventHelper {
|
|||
*/
|
||||
public EventHelper() {}
|
||||
|
||||
/**
|
||||
* Logs an event call.
|
||||
*
|
||||
* @param event event class
|
||||
* @param arguments arguments passed to event listeners
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static void logCall(@NotNull Class<? extends Event> event, @NotNull Object ... arguments) {
|
||||
// Print event call if event debugging is enabled
|
||||
if (EngineConfiguration.getInstance().isDebugEvents())
|
||||
if (arguments.length == 0)
|
||||
logger.diag("Event " + event.getName() + " was emitted");
|
||||
else
|
||||
logger.diag("Event " + event.getName() + " was emitted, passing arguments " + ListFormatter.formatArray(arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all {@link EventListener}s listening on some event.
|
||||
* The classpath will be scanned for listeners, unless cached results exist and {@code !forceScanning}.
|
||||
|
@ -149,8 +133,11 @@ public final class EventHelper {
|
|||
* @since v1-alpha0
|
||||
*/
|
||||
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
|
||||
if (event != LogEvent.class)
|
||||
logCall(event);
|
||||
if (event != LogEvent.class && EngineConfiguration.getInstance().isDebugEvents())
|
||||
if (arguments.length == 0)
|
||||
logger.diag("Event " + event.getName() + " was emitted");
|
||||
else
|
||||
logger.diag("Event " + event.getName() + " was emitted, passing arguments " + ListFormatter.formatArray(arguments));
|
||||
|
||||
Runnable eventCode = () -> {
|
||||
for (ReflectionMethod method : getAnnotatedMethods(event)) {
|
||||
|
|
Loading…
Reference in a new issue