diff --git a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java index bf274ff..0c934fa 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java @@ -82,6 +82,14 @@ public final class EngineConfiguration implements SubsystemConfiguration { */ private boolean debug; + /** + * If enabled, all called events will be logged. + * + * @see de.staropensource.sosengine.base.classes.helpers.EventHelper#logCall(Class) + * @since 1-alpha0 + */ + private boolean debugEvents; + /** * If enabled, very verbose messages about the {@link de.staropensource.sosengine.base.utility.ShortcodeConverter}'s internals will be printed.
* Don't enable unless you have knowledge about the {@link de.staropensource.sosengine.base.utility.ShortcodeConverter} and want to work on it. @@ -208,6 +216,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { try { switch (property) { case "debug" -> debug = parser.getBoolean(group + property); + case "debugEvents" -> debugEvents = parser.getBoolean(group + property); case "debugShortcodeConverter" -> debugShortcodeConverter = parser.getBoolean(group + property); case "errorShortcodeConverter" -> errorShortcodeConverter = parser.getBoolean(group + property); @@ -228,6 +237,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { // Disable all debug options if 'debug' is disabled if (!debug) { + debugEvents = false; debugShortcodeConverter = false; } } @@ -240,6 +250,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { /** {@inheritDoc} */ public void loadDefaultConfiguration() { debug = false; + debugEvents = false; debugShortcodeConverter = false; errorShortcodeConverter = true; @@ -257,6 +268,9 @@ public final class EngineConfiguration implements SubsystemConfiguration { case "debug" -> { return debug; } + case "debugEvents" -> { + return debugEvents; + } case "debugShortcodeConverter" -> { return debugShortcodeConverter; } diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index c0e665b..cfca209 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -19,10 +19,12 @@ package de.staropensource.sosengine.base.classes.helpers; +import de.staropensource.sosengine.base.EngineConfiguration; import de.staropensource.sosengine.base.annotations.EventListener; import de.staropensource.sosengine.base.classes.Event; import de.staropensource.sosengine.base.logging.Logger; import de.staropensource.sosengine.base.types.LogIssuer; +import de.staropensource.sosengine.base.utility.ListFormatter; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.reflections.Reflections; @@ -53,9 +55,12 @@ public class EventHelper { * @param clazz event class * @since 1-alpha0 */ - @NotNull - public static void logCall(Class clazz) { - Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called"); + public static void logCall(Class clazz, Object ... arguments) { + if (EngineConfiguration.getInstance().isDebugEvents()) + if (arguments.length == 0) + Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called"); + else + Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called with arguments " + ListFormatter.formatArray(arguments)); } /**