public class WholeLineProcessor extends LogReformatProcessor
DetailByDetailProcessor
which looks for individual values while
progressively parsing lines in the input log, this processor will parse an
entire log line at a time. Such an approach is better for simple
modifications (such inserting quotes around particular log details), while
the LogReformatProcessor is better at reformatting log lines by seeking
particular details within each line to manipulate how those details are
displayed.
Using the previous example (inserting quotes), let's assume we are presented
with the following line as input:
2015-03-01 09:50:21 W3SVC1234849874 10.10.1.73 GET /data/messenger/MSGRMDS_1001/DATA/2011_159/EW0216024357G.IMG - 80 - 106.188.24.48 Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko - 200 0 0 270336 -
This line is rather difficult to interpret, since one of it's values
contains spaces--thanks for that, GEO! We want to insert some quotes around
the log detail containing spaces, making it look like this:
2015-03-01 09:50:21 W3SVC1234849874 10.10.1.73 GET /data/messenger/MSGRMDS_1001/DATA/2011_159/EW0216024357G.IMG - 80 - 106.188.24.48 "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko" "-" 200 0 0 270336 -
To make this modification, we specify our input line specification:
The processor uses this pattern to generate a regular expression pattern that matches the entire line, captures all details within brackets, and generates output using an output line specification: "" " " It is important to note that unlike the DetailByDetailProcessor, this processor does not allow flags to be specified in either input or output line specifications. Indeed all log details noted in the input line specification are required.
Modifier and Type | Field and Description |
---|---|
static String |
OUTPUT_DIR_NAME |
DEFAULT_ERRORS_ALLOWED, errorLinesAllowed, inputDetailMap, outputDetailMap, segmentedInput, segmentedOutput
Constructor and Description |
---|
WholeLineProcessor() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Properties props)
Configure the Processor, providing the details needed to process logs.
|
String |
getDirName()
Get the name of the directory where the output of the processor is
placed.
|
String |
getOutputFileName(String inputFileName)
Get the name that will be assigned to an output file, given the input
file name.
|
protected void |
parseInputLine(String line)
Parse a line from an input file and extract the values for presented
details (e.g.
|
void |
process(File in,
File out)
Read in a log file, reformat it as per configured, and place the output
in the given directory.
|
void |
process(List<File> in,
File out)
Read in the log files in the given directory, reformat them as per
configured, and place the output in the given directory.
|
boolean |
verifyConfiguration()
Verify that the Processor has been properly configured.
|
configure, determineErrorTolerance, formatOutputLine, parseInputSpec, parseOutputSpec, processFile, processFileList, processLine, resetDetailMaps, validateLineSpecs
public static final String OUTPUT_DIR_NAME
public void process(File in, File out) throws ProcessingException
LogReformatProcessor
process
in interface Processor
process
in class LogReformatProcessor
in
- The File
that will be reformatted.out
- The directory where output will be placed,
represented as a File
.ProcessingException
- If any parameters are null or invalid, if
the processor hasn't been configured, or if
an error occurs during processing.public void process(List<File> in, File out) throws ProcessingException
LogReformatProcessor
process
in interface Processor
process
in class LogReformatProcessor
in
- A List
of File
s that will
be reformatted.out
- The directory where output will be placed,
represented as a File
.ProcessingException
- If any parameters are null or invalid, if
the processor hasn't been configured, or if
an error occurs during processing.gov.nasa.pds.report.processing.Processor.process()
public String getDirName()
Processor
public void configure(Properties props) throws ProcessingException
Processor
props
- A Properties
containing the needed
configuration values.ProcessingException
- If the provided Properties do not contain
the needed configuration values.public boolean verifyConfiguration()
Processor
verifyConfiguration
in interface Processor
verifyConfiguration
in class LogReformatProcessor
gov.nasa.pds.report.processing.Processor.verifyConfiguration()
public String getOutputFileName(String inputFileName)
Processor
inputFileName
- The name of the input fileprotected void parseInputLine(String line) throws ProcessingException
LogReformatProcessor
parseInputLine
in class LogReformatProcessor
line
- The input line, presented as a String.ProcessingException
- If a required detail is not defined, or if
the line cannot be properly parsed using
the pattern provided during configuration.Copyright © 2010–2017 Planetary Data System. All rights reserved.