+ String m = "";
+ while((s = br.readLine()) != null) m += s + "\n";
+ log(o, m.substring(0, m.length() - 1), level);
+ } catch (IOException e) {
+ System.err.println(colorize(RED, true, "Logger: exception thrown by ByteArrayInputStream -- this should not happen"));
+ }
+ return;
+ }
+
+ String str = message.toString();
+ while(str.indexOf('\t') != -1)
+ str = str.substring(0, str.indexOf('\t')) + " " + str.substring(str.indexOf('\t') + 1);
+
+ classname = colorize(GRAY, false, classname);
+ int levelcolor = GRAY;
+ boolean bright = true;
+ switch (level) {
+ case DIAGNOSTIC: levelcolor = GREEN; bright = false; break;
+ case ECHO: levelcolor = BLUE; bright = true; break;
+ case DEBUG: levelcolor = BLACK; bright = true; break;
+ case INFO: levelcolor = GRAY; bright = false; break;
+ case WARN: levelcolor = BROWN; bright = false; break;
+ case ERROR: levelcolor = RED; bright = true; break;
+ }
+
+ while(str.indexOf('\n') != -1) {
+ System.err.println(classname + colorize(levelcolor, bright, str.substring(0, str.indexOf('\n'))));
+ classname = logDates ? " " : " ";
+ classname = colorize(GRAY,false,classname);
+ str = str.substring(str.indexOf('\n') + 1);
+ }
+ System.err.println(classname + colorize(levelcolor, bright, str));
+ }
+
+ public static void recursiveLog(String indent, String name, Object o) throws JSExn {
+ if (!name.equals("")) name += " : ";
+
+ if (o == null) {
+ JS.log(indent + name + "<null>");
+
+ } else if (o instanceof JSArray) {
+ JS.log(indent + name + "<array>");
+ JSArray na = (JSArray)o;
+ for(int i=0; i<na.length(); i++)
+ recursiveLog(indent + " ", i + "", na.elementAt(i));
+
+ } else if (o instanceof JS) {
+ JS.log(indent + name + "<object>");
+ JS s = (JS)o;
+ Enumeration e = s.keys();
+ while(e.hasMoreElements()) {
+ Object key = e.nextElement();
+ if (key != null)
+ recursiveLog(indent + " ", key.toString(),
+ (key instanceof Integer) ?
+ s.get(((Integer)key)) : s.get(key.toString()));
+ }
+ } else {
+ JS.log(indent + name + o);