use of alma.acs.logging.engine.io.IOHelper in project ACS by ACS-Community.
the class LogFileExtractor method extract.
/**
* Extract the logs from the source to the destination
* applying the selection criteria given in the
* constructor
*/
public void extract() throws Exception {
IOHelper inputHelper = new IOHelper();
inputHelper.setFilters(filters);
openDestFile();
// Start the loading
if (inFileNames == null) {
// Read from stdin
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
inputHelper.loadLogs(in, this, null, this, this);
} else
for (String inFileName : inFileNames) {
System.out.println("Processing " + inFileName);
inputHelper.loadLogs(inFileName, this, null, this, this);
}
// Flush and close the output
outF.flush();
outF.close();
outF = null;
}
use of alma.acs.logging.engine.io.IOHelper in project ACS by ACS-Community.
the class LogFileSplitter method split.
/**
* Split the input file
* @throws Exception in case of errors while splitting
*/
public void split() throws Exception {
IOHelper ioHelper = new IOHelper();
if (inFileNames == null) {
// Read from stdin
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
ioHelper.loadLogs(in, this, null, this, this);
} else {
for (String inFileName : inFileNames) {
System.out.println("Processing " + inFileName);
ioHelper.loadLogs(inFileName, this, null, this, this);
}
}
if (outF != null) {
closeOutputFile(outF);
}
}
use of alma.acs.logging.engine.io.IOHelper in project ACS by ACS-Community.
the class LoadSaveTest method testLoadingSpecialLogs.
/**
* Load a set of special logs that could be interesting.
* <P>
* Initially this method opens an XML file and writes into it the special logs without using
* <code>IOHelper</code>.
* Then it tries to load the file containing the special logs
*
*
* @throws Exception
*/
public void testLoadingSpecialLogs() throws Exception {
FileWriter f = new FileWriter(fileName, false);
f.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<Log>\n<Header Name=\"NameForXmlDocument\" Type=\"LOGFILE\" />\n");
for (String xml : specialLogs) {
f.write(xml);
}
f.write("</Log>");
f.flush();
f.close();
IOHelper ioHelper = new IOHelper();
assertNotNull(ioHelper);
ioHelper.loadLogs(fileName, this, null, this, this, false);
// Check if the number of records is the same
assertEquals(specialLogs.length, logsRead.size());
}
Aggregations