Search in sources :

Example 6 with IOHelper

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;
}
Also used : InputStreamReader(java.io.InputStreamReader) IOHelper(alma.acs.logging.engine.io.IOHelper) BufferedReader(java.io.BufferedReader)

Example 7 with IOHelper

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) IOHelper(alma.acs.logging.engine.io.IOHelper) BufferedReader(java.io.BufferedReader)

Example 8 with IOHelper

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());
}
Also used : IOHelper(alma.acs.logging.engine.io.IOHelper) FileWriter(java.io.FileWriter)

Aggregations

IOHelper (alma.acs.logging.engine.io.IOHelper)8 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)4 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)1 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)1 LogField (com.cosylab.logging.engine.log.LogField)1 FileWriter (java.io.FileWriter)1 Vector (java.util.Vector)1