From aaa81e2f879fc99d1a622ecbbace4506263a8104 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 21 Jul 2024 21:19:10 +0200 Subject: [PATCH] Disallow logCall() invocation on LogEvent --- .../sosengine/base/classes/helpers/EventHelper.java | 4 +++- .../java/de/staropensource/sosengine/base/logging/Logger.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 4d8ad19..709f0a8 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 @@ -22,6 +22,7 @@ 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.events.LogEvent; import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException; import de.staropensource.sosengine.base.exceptions.reflection.InstanceMethodFromStaticContextException; import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodSignature; @@ -144,7 +145,8 @@ public class EventHelper { public static void invokeAnnotatedMethods(@NotNull Class event, Object... arguments) { Runnable eventCode = () -> { LoggerInstance logger = new LoggerInstance(new LogIssuer(EventHelper.class, event.getName(), CodePart.ENGINE)); - logCall(event); + if (event != LogEvent.class) + logCall(event); for (ReflectionMethod method : getAnnotatedMethods(event)) { try { diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java index 0094dfa..ed1f487 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java @@ -215,7 +215,8 @@ public final class Logger { base = loggerImplementation.postPlaceholder(level, issuer, base); // Call event - if (!(issuer.getClazz().getName().equals("de.staropensource.sosengine.slf4j_compat.CompatibilityLogger") || issuer.getClazz().equals(EventHelper.class))) + if (!(issuer.getClazz().getName().equals("de.staropensource.sosengine.slf4j_compat.CompatibilityLogger") + || issuer.getClazz().equals(EventHelper.class))) new LogEvent().callEvent(level, issuer, message); // Print log message by invoking LoggerImpl#print