Skip to content

Commit

Permalink
Adapted log-parser to include JSON in the commandline execution
Browse files Browse the repository at this point in the history
  • Loading branch information
baubakg committed Sep 25, 2024
1 parent 4d655bf commit 813a451
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ java -jar log-parser-1.11.0.jar --startDir=/path/to/logs --parseDefinition=/path

You can provide additional information such as:
* `--fileFilter` : The wildcard used for selecting the log files. The default value is *.log
* `--reportType` : The format of the report. The allowed values are currently HTML & CSV. The default value is HTML
* `--reportType` : The format of the report. The allowed values are currently HTML, JSON & CSV. The default value is HTML
* `--reportFileName` : The name of the report file. By default, this is the name of the Parse Definition name suffixed with '-export'
* `--reportName` : The report title as show in an HTML report. By default, the title includes the Parse Definition name

Expand All @@ -472,6 +472,7 @@ All reports are stored in the directory `log-parser-reports/export/`.
- **(new feature)** [#138](https://github.com/adobe/log-parser/issues/138) We now have the possibility of anonymizing log data during parsing. For more information please read the section on [Anonymizing Data](#anonymizing-data).
- **(new feature)** [#117](https://github.com/adobe/log-parser/issues/117) You can now include the file name in the result of the analysis.
- **(new feature)** [#141](https://github.com/adobe/log-parser/issues/141) You can now export a LogData as a table in a HTML file.
- **(new feature)** [#173](https://github.com/adobe/log-parser/issues/173) You can now export a LogData as a JSON file.
- **(new feature)** [#123](https://github.com/adobe/log-parser/issues/123) We now log the total number and size of the parsed files.
- [#110](https://github.com/adobe/log-parser/issues/110) Moved to Java 11
- [#169](https://github.com/adobe/log-parser/issues/169) We only keep one Parse Definition entry with the same title in a Parse Definition.
Expand Down
30 changes: 19 additions & 11 deletions src/main/java/com/adobe/campaign/tests/logparser/RunLogParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,26 @@ public static void main(String[] in_args) throws StringParseException {
l_targetSDKClass);

//Generate Report
if (RunArguments.REPORT_FORMAT.fetchValue(in_args).equalsIgnoreCase("CSV")) {
l_logData.exportLogDataToCSV(RunArguments.REPORT_FILENAME.fetchValue(in_args,
l_parseDefinition.fetchEscapedTitle() + "-export.csv"));
} else if (RunArguments.REPORT_FORMAT.fetchValue(in_args).equalsIgnoreCase("HTML")) {
l_logData.exportLogDataToHTML(
RunArguments.REPORT_NAME.fetchValue(in_args, l_parseDefinition.getTitle()),
RunArguments.REPORT_FILENAME.fetchValue(in_args,
l_parseDefinition.fetchEscapedTitle() + "-export.html"));
} else {
System.err.println("The report format " + RunArguments.REPORT_FORMAT.fetchValue(in_args)
+ " is not supported.");
switch (RunArguments.REPORT_FORMAT.fetchValue(in_args).toUpperCase()) {
case "CSV":
l_logData.exportLogDataToCSV(RunArguments.REPORT_FILENAME.fetchValue(in_args,
l_parseDefinition.fetchEscapedTitle() + "-export.csv"));
break;
case "HTML":
l_logData.exportLogDataToHTML(
RunArguments.REPORT_NAME.fetchValue(in_args, l_parseDefinition.getTitle()),
RunArguments.REPORT_FILENAME.fetchValue(in_args,
l_parseDefinition.fetchEscapedTitle() + "-export.html"));
break;
case "JSON":
l_logData.exportLogDataToJSON(RunArguments.REPORT_FILENAME.fetchValue(in_args,
l_parseDefinition.fetchEscapedTitle() + "-export.json"));
break;

Check warning on line 81 in src/main/java/com/adobe/campaign/tests/logparser/RunLogParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/adobe/campaign/tests/logparser/RunLogParser.java#L79-L81

Added lines #L79 - L81 were not covered by tests
default:
System.err.println("The report format " + RunArguments.REPORT_FORMAT.fetchValue(in_args)
+ " is not supported.");
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum RunArguments {
"The SDK class to be used for transforming the log data to objects. It is just the class name.",
"com.adobe.campaign.tests.logparser.core.GenericEntry"),
REPORT_FORMAT("reportType", false,
"The format of the report. The allowed values are currently HTML & CSV.", "HTML"),
"The format of the report. The allowed values are currently HTML, JSON & CSV.", "HTML"),
REPORT_FILENAME("reportFileName", false, "The name of the report file. By default, this is the name of the Parse Definition name suffixed with '-export'", ""),
REPORT_NAME("reportName", false, "The report title as show in an HTML report. By default the title includes the Parse Definition name", ""),

Expand Down

0 comments on commit 813a451

Please sign in to comment.