-// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
+// Copyright 2003 Adam Megacz, see the COPYING file for licensing [LGPL]
package org.xwt.util;
+import org.xwt.js.*;
import java.io.*;
import java.util.*;
/** true iff nothing has yet been logged */
public static boolean firstMessage = true;
+ /** log a message with the current JavaScript sourceName/line */
+ public static void logJS(Object o, Object message) { logJS(message); }
+ public static void logJS(Object message) { log(JS.getSourceName() + ":" + JS.getLine(), message); }
+
/** message can be a String or a Throwable */
public static synchronized void log(Object o, Object message) {
-
if (firstMessage && !logDates) {
firstMessage = false;
System.err.println("===========================================================================");
}
}
+ public static void recursiveLog(String indent, String name, Object o) throws JSExn {
+ if (!name.equals("")) name += " : ";
+
+ if (o == null) {
+ Log.logJS(indent + name + "<null>");
+
+ } else if (o instanceof JSArray) {
+ Log.logJS(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) {
+ Log.logJS(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 {
+ Log.logJS(indent + name + o);
+
+ }
+ }
+
}