import java.net.*;
import java.io.*;
+import java.util.*;
import org.ibex.js.*;
import org.ibex.util.*;
public static Picture scarImage = null;
public static void printUsage() {
- System.err.println("Usage: ibex [-s] [-v] [-l <port>/<url>] source-location [initial-template]");
+ System.err.println("Usage: ibex [-lawp] [ url | file | directory ]");
System.err.println("");
- System.err.println("Options:");
- System.err.println(" -v verbose logging (required for logging on Win32)");
- System.err.println(" -s [not yet supported]");
- System.err.println(" -l [not yet supported]");
- System.err.println("");
- System.err.println("Source-location is one of the following:");
- System.err.println(" - the path to an xwar file");
- System.err.println(" - the path to a directory to be used as an xwar");
- System.err.println(" - the http url of an xwar");
- System.err.println("");
- System.err.println("Initial-template is the path of the template to load; defaults to 'main'");
+ System.err.println(" -l <level> set logging level to { debug, info (default), warn, error, silent }");
+ System.err.println(" -l rpc log all XML-RPC and SOAP conversations");
+ System.err.println(" -l user@host email log to user@host");
+ System.err.println(" -l host:port emit log to TCP socket");
+ System.err.println(" -l <file> write log to a file on disk");
+ System.err.println(" -a check assertions");
+ System.err.println(" -w <window-id> reserved for libibex");
+ System.err.println(" -p dump profiling information [not yet supported]");
Runtime.getRuntime().exit(-1);
}
- public static void main(String[] args) throws UnknownHostException, JSExn {
+ public static void main(String[] args) throws UnknownHostException, JSExn, IOException {
int startargs = 0;
while (true) {
if (startargs > args.length - 1) printUsage();
- else if (args[startargs].equals("-v")) Log.verbose = true;
+ else if (args[startargs].equals("-a")) JS.checkAssertions = true;
+ else if (args[startargs].equals("-l")) {
+ startargs++;
+ StringTokenizer opts = new StringTokenizer(args[startargs], ",");
+ while(opts.hasMoreTokens()) {
+ String opt = opts.nextToken();
+ if (opt.indexOf('@') != -1) Log.email(opt);
+ else if (opt.indexOf(':') != -1)
+ Log.tcp(opt.substring(0, opt.indexOf(':')),
+ Integer.parseInt(opt.substring(opt.indexOf(':') + 1)));
+ else if (opt.equals("debug")) Log.level = Log.DEBUG;
+ else if (opt.equals("info")) Log.level = Log.INFO;
+ else if (opt.equals("warn")) Log.level = Log.WARN;
+ else if (opt.equals("error")) Log.level = Log.ERROR;
+ else if (opt.equals("silent")) Log.level = Log.SILENT;
+ else if (opt.equals("rpc")) Log.rpc = true;
+ else Log.file(opt);
+ }
+ }
else break;
startargs++;
}
scarImage =
Picture.load((Stream)Main.builtin.get("org/ibex/builtin/scar.png"),
new Scheduler.Task() { public void perform() throws JSExn, UnknownHostException {
+ if (Log.on) Log.info(Main.class, "invoking initial template");
ibex.resolveString(startupTemplate, false).call(new Box(), null, null, null, 1);
} });