diff --git a/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleBuilder.java b/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleBuilder.java index 974690ee..d0ddf316 100644 --- a/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleBuilder.java +++ b/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleBuilder.java @@ -21,6 +21,7 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.Nullable; import org.openhab.automation.jrule.internal.engine.excutioncontext.JRuleChannelExecutionContext; import org.openhab.automation.jrule.internal.engine.excutioncontext.JRuleItemChangeExecutionContext; @@ -148,7 +149,7 @@ public boolean build() { uid = UUID.randomUUID().toString(); } - if (logName == null) { + if (StringUtils.isEmpty(logName)) { logName = ruleName; } diff --git a/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleEngine.java b/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleEngine.java index 649db036..db72e86f 100644 --- a/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleEngine.java +++ b/src/main/java/org/openhab/automation/jrule/internal/engine/JRuleEngine.java @@ -512,11 +512,12 @@ public JRuleBuilder createJRuleBuilder(String ruleName, JRule jRule, Method meth } else { method.invoke(jRule); } - } catch (IllegalAccessException | IllegalArgumentException | SecurityException e) { - logError("Error calling rule method: {}", ExceptionUtils.getStackTrace(e)); } catch (InvocationTargetException e) { logError("Error in rule: {}\ntarget: {}", ExceptionUtils.getStackTrace(e), ExceptionUtils.getStackTrace(e.getCause())); + } catch (IllegalAccessException | IllegalArgumentException | SecurityException e) { + logError("Error calling rule method '{}#{}': {}", method.getDeclaringClass().getName(), + method.getName(), ExceptionUtils.getStackTrace(e)); } }).uid(JRuleModuleEntry.createUid(jRule, method)); } diff --git a/src/test/java/org/openhab/automation/jrule/rules/integration_test/ITJRule.java b/src/test/java/org/openhab/automation/jrule/rules/integration_test/ITJRule.java index 6ccb5c2f..5ea66a3e 100644 --- a/src/test/java/org/openhab/automation/jrule/rules/integration_test/ITJRule.java +++ b/src/test/java/org/openhab/automation/jrule/rules/integration_test/ITJRule.java @@ -34,6 +34,7 @@ public void switchItemReceiveCommand() throws IOException { verifyRuleWasExecuted(TestRules.NAME_SWITCH_ITEM_RECEIVED_ANY_COMMAND); verifyRuleWasExecuted(TestRules.NAME_SWITCH_ITEM_RECEIVED_ANY_UPDATE); verifyRuleWasExecuted(TestRules.NAME_SWITCH_ITEM_CHANGED); + verifyLogEntry("[%s/%s]".formatted(TestRules.NAME_SWITCH_ITEM_RECEIVED_ANY_COMMAND, TestRules.TAG_CUSTOM)); } @Test diff --git a/src/test/java/org/openhab/automation/jrule/rules/user/TestRules.java b/src/test/java/org/openhab/automation/jrule/rules/user/TestRules.java index d25cd2be..e71ec008 100755 --- a/src/test/java/org/openhab/automation/jrule/rules/user/TestRules.java +++ b/src/test/java/org/openhab/automation/jrule/rules/user/TestRules.java @@ -142,7 +142,9 @@ public class TestRules extends JRule { public static final String COMMAND_GROUPS = "groups"; public static final String NAME_TRIGGER_ON_GROUP_STATE_CHANGE = "trigger on group state change"; public static final String ITEM_SWITCH_GROUP_OR = "SwitchGroupOr"; + public static final String TAG_CUSTOM = "custom"; + @JRuleTag({ TAG_CUSTOM }) @JRuleName(NAME_SWITCH_ITEM_RECEIVED_ANY_COMMAND) @JRuleWhenItemReceivedCommand(item = ITEM_RECEIVING_COMMAND_SWITCH) public void switchItemReceivedCommand(JRuleItemEvent event) { diff --git a/src/test/resources/docker/log4j2.xml b/src/test/resources/docker/log4j2.xml index 40bd5a36..9f8a27de 100755 --- a/src/test/resources/docker/log4j2.xml +++ b/src/test/resources/docker/log4j2.xml @@ -3,61 +3,16 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -