[rules-users] Drools mvel consequence if (logEnabled) discussion/disabled if statement

AberAber maryellenbench at hotmail.com
Wed Apr 13 11:06:14 EDT 2011


I know I've seen other posts saying that if statement in consequence has been
disabled due to it being poor practice, but I see the use in logging.

Lets say in consequence I have a complicated rule with 5 conditions and an
action:

modify($score) {
    value = $score.value + 1;
}
if (log.debugEnabled) // errors since no if statement
{
      log.debug("Added score + 1 for file " + $file + " now has updated
score of "+ $score.value);
}

This is impossible in mvel as if statement is disabled.  I still want my
rule to fire if debug is disabled, so I can't add eval(log.debugEnabled) to
rule.

A stupid workaround is
for (int x = 0; ((x < 1) && log.debugEnabled); x = x + 1) {

I have a bunch of rules with different log change statements, so I see the
use of adding if statement back for mvel.   

Is there a better workaround?

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-mvel-consequence-if-logEnabled-discussion-disabled-if-statement-tp2816469p2816469.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list