74582d6e by Adam Heath

Improve the logging format a little bit.

1 parent acfc8c96
......@@ -4,7 +4,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.brainfood.rhino.Console;
......@@ -49,16 +51,28 @@ public class OfbizRhinoContainer extends RhinoContainer<OfbizRhinoContainer> {
return "OfbizConsole";
}
private static void addOneLogItem(StringBuilder format, List<Object> logArgs, Object logItem) {
if (logItem == null) {
format.append("%s");
logArgs.add(null);
} else {
logArgs.add(Context.toString(logItem));
logArgs.add(logItem.getClass().getName());
format.append("%s<%s>");
}
}
public void log(Context cx, Object[] args, Function funObj) {
Object[] sargs = Console.getSArgs(args);
StringBuilder format = new StringBuilder();
List<Object> logArgs = new ArrayList(args.length * 2 + 1);
format.append(':');
for (int i = 0; i < args.length; i++) {
if (i != 0) {
format.append(", ");
}
format.append("%s");
addOneLogItem(format, logArgs, args[i]);
}
Debug.logInfo(format.toString(), module, sargs);
Debug.logInfo(format.toString(), module, logArgs.toArray(new Object[logArgs.size()]));
}
}
......