

Public Member Functions | |
| LogFileSplitter (String[] inputFiles, String outputFiles, Integer num, Integer mins, LogConverter converter) | |
| void | split () throws Exception |
| void | bytesRead (long bytes) |
| void | bytesWritten (long bytes) |
| void | logsRead (int numOfLogs) |
| void | logsWritten (int numOfLogs) |
| void | errorReceived (String xml) |
| void | logEntryReceived (ILogEntry logEntry) |
Private Member Functions | |
| BufferedWriter | getOutputFile (String dest, int idx, Date startingDate) |
| void | closeOutputFile (BufferedWriter file) |
Private Attributes | |
| String[] | inFileNames |
| String | destFileName |
| int | index = 0 |
| Integer | number = null |
| Integer | time = null |
| int | logsRead = 0 |
| long | firstLogDate = -1 |
| final int | OUTPUT_BUFFER_SIZE = 8192 |
| BufferedWriter | outF = null |
| SimpleDateFormat | dateFormat = new IsoDateFormat() |
| final LogConverter | converter |
An object to split a log file in several other shorter file. The criteria is the number of logs or the time (in minutes)
A progressive number is appended to the name of the destination for each created file. If the time is the criteria to split the input file, the the date of the first log is appended to the name of the file too.
| alma::acs::logging::tools::LogFileSplitter::LogFileSplitter | ( | String[] | inputFiles, | |
| String | outputFiles, | |||
| Integer | num, | |||
| Integer | mins, | |||
| LogConverter | converter | |||
| ) | [inline] |
Constructor
| inputFiles | The files of log to read | |
| outputFiles | The names of the files created splitting | |
| num | The number of logs per file (can be null) | |
| mins | The minutes of the logs per file (can be null) | |
| converter | The converter to format the logs before saving |
References destFileName, inFileNames, number, and time.
| void alma::acs::logging::tools::LogFileSplitter::bytesRead | ( | long | bytes | ) | [inline] |
| void alma::acs::logging::tools::LogFileSplitter::bytesWritten | ( | long | bytes | ) | [inline] |
| void alma::acs::logging::tools::LogFileSplitter::closeOutputFile | ( | BufferedWriter | file | ) | [inline, private] |
Flush and close the file
| file | The file to close |
Referenced by logEntryReceived(), and split().
| void alma::acs::logging::tools::LogFileSplitter::errorReceived | ( | String | xml | ) | [inline] |
Implements com::cosylab::logging::engine::ACS::ACSRemoteErrorListener.
| BufferedWriter alma::acs::logging::tools::LogFileSplitter::getOutputFile | ( | String | dest, | |
| int | idx, | |||
| Date | startingDate | |||
| ) | [inline, private] |
Create a new file for output.
| dest | The name of the destination file | |
| index | The index to append to the name | |
| startingDate | The date of the first log to append to the name of the file It can be null. |
References converter, dateFormat, and OUTPUT_BUFFER_SIZE.
Referenced by logEntryReceived().
| void alma::acs::logging::tools::LogFileSplitter::logEntryReceived | ( | ILogEntry | logEntry | ) | [inline] |
Implements com::cosylab::logging::engine::ACS::ACSRemoteLogListener.
References closeOutputFile(), alma::acs::logging::tools::LogConverter::convert(), converter, destFileName, firstLogDate, com::cosylab::logging::engine::log::ILogEntry::getField(), getOutputFile(), index, logsRead, number, outF, and time.
| void alma::acs::logging::tools::LogFileSplitter::logsRead | ( | int | numOfLogs | ) | [inline] |
| void alma::acs::logging::tools::LogFileSplitter::logsWritten | ( | int | numOfLogs | ) | [inline] |
| void alma::acs::logging::tools::LogFileSplitter::split | ( | ) | throws Exception [inline] |
Split the input file
| Exception | in case of errors while splitting |
References closeOutputFile(), inFileNames, alma::acs::logging::engine::io::IOHelper::loadLogs(), and outF.
Referenced by alma::acs::logging::tools::LogAssistant::splitFile().
final LogConverter alma::acs::logging::tools::LogFileSplitter::converter [private] |
The converter to format the log before saving
Referenced by getOutputFile(), and logEntryReceived().
SimpleDateFormat alma::acs::logging::tools::LogFileSplitter::dateFormat = new IsoDateFormat() [private] |
The format of the date in the name of the file
Referenced by getOutputFile().
String alma::acs::logging::tools::LogFileSplitter::destFileName [private] |
The name for the output files
A progressive number/starting date is appended at the end of each name
Referenced by logEntryReceived(), and LogFileSplitter().
long alma::acs::logging::tools::LogFileSplitter::firstLogDate = -1 [private] |
The date of the first log in the current output file (needed for time criteria)
Referenced by logEntryReceived().
int alma::acs::logging::tools::LogFileSplitter::index = 0 [private] |
The progressive number appended at the end of each generated file
Referenced by logEntryReceived().
String [] alma::acs::logging::tools::LogFileSplitter::inFileNames [private] |
The name of the input files
Referenced by LogFileSplitter(), and split().
int alma::acs::logging::tools::LogFileSplitter::logsRead = 0 [private] |
Counts the number of logs read (needed for number criteria)
Referenced by logEntryReceived().
Integer alma::acs::logging::tools::LogFileSplitter::number = null [private] |
The number of logs in each splitted file
Referenced by logEntryReceived(), and LogFileSplitter().
BufferedWriter alma::acs::logging::tools::LogFileSplitter::outF = null [private] |
The writer to write the destination files
Referenced by logEntryReceived(), and split().
final int alma::acs::logging::tools::LogFileSplitter::OUTPUT_BUFFER_SIZE = 8192 [private] |
The size of the buffer for writing
Referenced by getOutputFile().
Integer alma::acs::logging::tools::LogFileSplitter::time = null [private] |
The time frame of the logs in each splitted file (in msec)
Referenced by logEntryReceived(), and LogFileSplitter().
1.6.2