for (int i = 0; i < selectedTerminals.size(); i++) {
GenericTerminal terminal = selectedTerminals.get(i);
//terminal.closeAllLogs();//this close System.out !
for (ScardLogHandler logHandler : terminal.getLogs()) {
if (logHandler instanceof ScardPrintStreamLogHandler) {
ScardPrintStreamLogHandler printStreamLogHandler = (ScardPrintStreamLogHandler) logHandler;
if (printStreamLogHandler.getPrintStream() == System.out) {
terminal.removeLog(logHandler);
} else {
terminal.closeLog(logHandler);
}
} else {
terminal.closeLog(logHandler);
}
}
String baseName = outputFile.getAbsolutePath();
String ext = AFileUtilities.extractFileExtension(baseName);
String name = terminal.getName() ;
//TODO: make sure that name don't contain forbiden characters like ":" and so on...
name=name.replace(':', '_');
name=name.replace('\\', '_');
name=name.replace('/', '_');
name=name.replace('*', '_');
name=baseName.substring(0, baseName.length() - ext.length()) +name+ "." + ext;
File logFile = new File(name);
logFiles.set(i, logFile);
PrintStream ps = new PrintStream(logFile);
ScardPrintStreamLogHandler printStreamLogHandler = new ScardPrintStreamLogHandler(ps);
terminal.addLogHandler(printStreamLogHandler);
}
System.out.println("Logging to " + outputFile.getCanonicalPath());
//outputFile = null;
//argContext.setOutputFile(null);