74582d6e by Adam Heath

Improve the logging format a little bit.

1 parent acfc8c96
...@@ -4,7 +4,9 @@ import java.io.File; ...@@ -4,7 +4,9 @@ import java.io.File;
4 import java.io.FileNotFoundException; 4 import java.io.FileNotFoundException;
5 import java.io.FileReader; 5 import java.io.FileReader;
6 import java.io.IOException; 6 import java.io.IOException;
7 import java.util.ArrayList;
7 import java.util.HashMap; 8 import java.util.HashMap;
9 import java.util.List;
8 import java.util.Map; 10 import java.util.Map;
9 11
10 import com.brainfood.rhino.Console; 12 import com.brainfood.rhino.Console;
...@@ -49,16 +51,28 @@ public class OfbizRhinoContainer extends RhinoContainer<OfbizRhinoContainer> { ...@@ -49,16 +51,28 @@ public class OfbizRhinoContainer extends RhinoContainer<OfbizRhinoContainer> {
49 return "OfbizConsole"; 51 return "OfbizConsole";
50 } 52 }
51 53
54 private static void addOneLogItem(StringBuilder format, List<Object> logArgs, Object logItem) {
55 if (logItem == null) {
56 format.append("%s");
57 logArgs.add(null);
58 } else {
59 logArgs.add(Context.toString(logItem));
60 logArgs.add(logItem.getClass().getName());
61 format.append("%s<%s>");
62 }
63 }
64
52 public void log(Context cx, Object[] args, Function funObj) { 65 public void log(Context cx, Object[] args, Function funObj) {
53 Object[] sargs = Console.getSArgs(args);
54 StringBuilder format = new StringBuilder(); 66 StringBuilder format = new StringBuilder();
67 List<Object> logArgs = new ArrayList(args.length * 2 + 1);
68 format.append(':');
55 for (int i = 0; i < args.length; i++) { 69 for (int i = 0; i < args.length; i++) {
56 if (i != 0) { 70 if (i != 0) {
57 format.append(", "); 71 format.append(", ");
58 } 72 }
59 format.append("%s"); 73 addOneLogItem(format, logArgs, args[i]);
60 } 74 }
61 Debug.logInfo(format.toString(), module, sargs); 75 Debug.logInfo(format.toString(), module, logArgs.toArray(new Object[logArgs.size()]));
62 } 76 }
63 } 77 }
64 78
......