Disallow logCall() invocation on LogEvent

This commit is contained in:
JeremyStar™ 2024-07-21 21:19:10 +02:00
parent 9d3397888d
commit aaa81e2f87
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 5 additions and 2 deletions

View file

@ -22,6 +22,7 @@ package de.staropensource.sosengine.base.classes.helpers;
import de.staropensource.sosengine.base.EngineConfiguration; import de.staropensource.sosengine.base.EngineConfiguration;
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.events.LogEvent;
import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException; import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException;
import de.staropensource.sosengine.base.exceptions.reflection.InstanceMethodFromStaticContextException; import de.staropensource.sosengine.base.exceptions.reflection.InstanceMethodFromStaticContextException;
import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodSignature; import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodSignature;
@ -144,7 +145,8 @@ public class EventHelper {
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) { public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
Runnable eventCode = () -> { Runnable eventCode = () -> {
LoggerInstance logger = new LoggerInstance(new LogIssuer(EventHelper.class, event.getName(), CodePart.ENGINE)); 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)) { for (ReflectionMethod method : getAnnotatedMethods(event)) {
try { try {

View file

@ -215,7 +215,8 @@ public final class Logger {
base = loggerImplementation.postPlaceholder(level, issuer, base); base = loggerImplementation.postPlaceholder(level, issuer, base);
// Call event // 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); new LogEvent().callEvent(level, issuer, message);
// Print log message by invoking LoggerImpl#print // Print log message by invoking LoggerImpl#print