rabbah commented on a change in pull request #444: Allow log stripping to
tolerate a missing stream identifier.
URL:
https://github.com/apache/incubator-openwhisk-cli/pull/444#discussion_r297707945
##########
File path: commands/util.go
##########
@@ -273,11 +273,15 @@ func makeDefaultHeader(collection interface{}) string {
}
func stripTimestamp(log string) (strippedLog string) {
- regex := regexp.MustCompile("[a-zA-Z0-9\\s]*(stdout|stderr):\\s(.*)")
+ // parses out the timestamp if it exists first
+ // the timestamp expected format is YYYY-MM-DDTHH:MM:SS.[0-9]+Z
+ // an optional " stdout" or " stderr" stream identifier
+ // and the rest as the log line
+ regex :=
regexp.MustCompile("\\d{4}-[01]{1}\\d{1}-[0-3]{1}\\d{1}T[0-2]{1}\\d{1}:[0-6]{1}\\d{1}:[0-6]{1}\\d{1}.\\d+Z(
(stdout|stderr):)?\\s(.*)")
Review comment:
this regex does make a semantic change.
previously, the following line
`anything stdout: this is stdout`
would be stripped to
`this is stdout`
but with this patch the line will remain intact.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services