ServiceReference sr = bc.getServiceReference(LOGREADER);
if (sr == null) {
out.println("Unable to get a LogReaderService");
return new Integer(1);
}
LogReaderService lr = (LogReaderService) bc
.getService(sr);
if (lr == null) {
out.println("Unable to get a LogReaderService");
return new Integer(1);
}
ArrayList bv = null;
String[] selection = (String[]) opts.get("bundle");
if (selection != null) {
Bundle[] b = bc.getBundles();
Util.selectBundles(b, selection);
bv = new ArrayList();
for (int i = 0; i < b.length; i++) {
if (b[i] != null) {
bv.add(b[i]);
}
}
}
boolean fflag = opts.get("-f") != null;
String lflag = (String) opts.get("-l");
int level;
if (lflag != null) {
if (lflag.equalsIgnoreCase("error")) {
level = LogService.LOG_ERROR;
} else if (lflag.equalsIgnoreCase("warning")) {
level = LogService.LOG_WARNING;
} else if (lflag.equalsIgnoreCase("info")) {
level = LogService.LOG_INFO;
} else if (lflag.equalsIgnoreCase("debug")) {
level = LogService.LOG_DEBUG;
} else {
out.println("Unknown level: " + lflag);
return new Integer(1);
}
} else {
level = LogService.LOG_DEBUG;
}
String hflag = (String) opts.get("-h");
long startTime = 0;
if (hflag != null) {
try {
startTime = System.currentTimeMillis()
- (long) (60 * 60 * 1000 * (new Double(
hflag)).doubleValue());
} catch (NumberFormatException e) {
out
.println("Illegal number of hours: "
+ hflag);
return new Integer(1);
}
}
String nflag = (String) opts.get("-n");
int count = Integer.MAX_VALUE;
if (nflag != null) {
try {
count = Integer.parseInt(nflag);
} catch (NumberFormatException e) {
out
.println("Illegal number as count: "
+ nflag);
return new Integer(1);
}
}
Enumeration e = lr.getLog();
Vector lv = new Vector();
boolean rflag = opts.get("-r") == null;
while (e.hasMoreElements()) {
LogEntry le = (LogEntry) e.nextElement();
Bundle b = le.getBundle();