forked from StarOpenSource/Engine
Extend event logging functionality
This commit is contained in:
parent
c11fc78b86
commit
0031c4ef29
2 changed files with 22 additions and 3 deletions
|
@ -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.<br/>
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -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<? extends Event> clazz) {
|
||||
public static void logCall(Class<? extends Event> 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue