Skip to content

Commit

Permalink
improved logging
Browse files Browse the repository at this point in the history
Issue #822
  • Loading branch information
rsoika committed Apr 24, 2023
1 parent d92fb86 commit 10c20a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,8 @@ public boolean evaluateBooleanExpression(String script, ItemCollection workitem)

// Test if we have a deprecated Script...
if (RuleEngineNashornConverter.isDeprecatedScript(script)) {
logger.warning("converting deprecated nashorn script");
logger.info("Old Script: \n=========================\n" + script + "\n=========================");
// here we rewrite the script as best as we can.
script = RuleEngineNashornConverter.rewrite(script, workitem, null);
logger.info("New Script: \n=========================\n" + script + "\n=========================");
script = RuleEngineNashornConverter.rewrite(script, workitem, null);
}

Value result = null;
Expand Down Expand Up @@ -247,10 +244,8 @@ public ItemCollection evaluateBusinessRule(String script, ItemCollection workite

// Test if we have a deprecated Script...
if (RuleEngineNashornConverter.isDeprecatedScript(script)) {
logger.warning("evaluate deprecated nashorn script");
// here we rewrite the script as best as we can.
script = RuleEngineNashornConverter.rewrite(script, workitem, event);
logger.info("New Script: \n=========================\n" + script + "\n=========================");
}

// evaluate the script....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,27 @@ public static boolean isDeprecatedScript(String script) {
* @return
*/
public static String rewrite(String script, ItemCollection workitem, ItemCollection event) {
logger.fine("rewrite scipt: " + script);

String converterLog="";
converterLog=converterLog+"\n***************************************************";
converterLog=converterLog+"\n*** DEPRECATED NASHORN SCRIPT FOUND: ***";
converterLog=converterLog+"\n***************************************************\n";

converterLog=converterLog+"\n" + script + "\n\n";

script = convertByItemCollection(script, workitem, "workitem");
script = convertByItemCollection(script, event, "event");
// here it may happen the something like
// workitem.getItemValueString(refField)[0]
// is the result. We need to remove the [0] here!
script = script.replace(")[0]", ")");

converterLog=converterLog+"\n***************************************************";
converterLog=converterLog+"\n*** PLEASE REPLACE YOUR SCRIPT WITH: ***";
converterLog=converterLog+"\n***************************************************\n";
converterLog=converterLog+"\n" + script + "\n";
converterLog=converterLog+"\n***************************************************\n";
logger.warning(converterLog);
return script;

}
Expand Down

0 comments on commit 10c20a7

Please sign in to comment.