[ 
https://issues.apache.org/jira/browse/GEODE-8798?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17261658#comment-17261658
 ] 

ASF GitHub Bot commented on GEODE-8798:
---------------------------------------

DonalEvans commented on a change in pull request #5863:
URL: https://github.com/apache/geode/pull/5863#discussion_r554241132



##########
File path: 
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptor.java
##########
@@ -106,8 +159,78 @@ public ResultModel postExecution(GfshParseResult 
parseResult, ResultModel comman
     }
 
     // if there is no downloaded file. File is saved on the locator/manager.
-    return ResultModel.createInfo(
-        "Logs exported to the connected member's file system: "
-            + commandResult.getFileToDownload().toString());
+    output.append("Logs exported to the connected member's file system: ")
+        .append(commandResult.getFileToDownload().toString());
+    return ResultModel.createInfo(output.toString());
+  }
+
+  private ResultModel checkStartAndEndFormat(String start, String end) {
+    StringBuilder formatErrorMessage = new StringBuilder();
+    boolean formatError = false;
+    if (start != null && !DATE_AND_TIME_PATTERN.matcher(start).matches()
+        && !DATE_ONLY_PATTERN.matcher(start).matches()) {
+      formatErrorMessage.append(EXPORT_LOGS__STARTTIME);
+      formatError = true;
+    }
+
+    if (end != null && !DATE_AND_TIME_PATTERN.matcher(end).matches()
+        && !DATE_ONLY_PATTERN.matcher(end).matches()) {
+      if (formatError) {
+        formatErrorMessage.append(" and ");
+      }
+      formatErrorMessage.append(EXPORT_LOGS__ENDTIME);
+      formatError = true;
+    }
+
+    if (formatError) {
+      formatErrorMessage.append(" had incorrect format. Valid formats are ")
+          .append(ONLY_DATE_FORMAT).append(" and ").append(FORMAT);
+      return ResultModel.createError(formatErrorMessage.toString());
+    }
+    return null;
+  }
+
+  private ResultModel checkStartAndEndParsing(String start, String end) {
+    StringBuilder parseErrorMessage = new StringBuilder();
+    boolean parseError = false;
+
+    SimpleDateFormat dateAndTimeFormat = new SimpleDateFormat(FORMAT);
+    SimpleDateFormat dateOnlyFormat = new SimpleDateFormat(ONLY_DATE_FORMAT);
+    if (start != null) {
+      try {
+        // If the input is intended to be parsed as date and time, use the 
date and time format
+        if (start.length() > 10) {
+          dateAndTimeFormat.parse(start);
+        } else {
+          dateOnlyFormat.parse(start);
+        }
+      } catch (ParseException e) {

Review comment:
       The error message from the ParseException is simply "Unparseable date: " 
followed by the user input, so it doesn't add any useful information here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> export logs command with --start-time or --end-time arguments needs 
> improvement
> -------------------------------------------------------------------------------
>
>                 Key: GEODE-8798
>                 URL: https://issues.apache.org/jira/browse/GEODE-8798
>             Project: Geode
>          Issue Type: Improvement
>          Components: docs, gfsh
>    Affects Versions: 1.12.0, 1.14.0, 1.13.1
>            Reporter: Donal Evans
>            Assignee: Donal Evans
>            Priority: Major
>              Labels: pull-request-available
>
> If an invalid or improperly formatted argument for --start-time or --end-time 
> is provided to the export logs gfsh command, the actual time cutoffs used to 
> determine which logs to export may be inconsistent or unexpected, but no 
> indication is given to the user that anything is wrong.
> In addition to this, the documentation for the command could be made clearer 
> to better allow users to understand the correct use of the arguments.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to