[GitHub] mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs
mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs URL: https://github.com/apache/incubator-openwhisk-cli/pull/292#discussion_r186783736 ## File path: commands/util.go ## @@ -280,14 +280,22 @@ func printFullActivationList(activations []whisk.Activation) { } } -func printActivationLogs(logs []string) { +func printStrippedActivationLogs(logs []string) { for _, log := range logs { - if Flags.activation.strip { - fmt.Printf("%s\n", log[39:]) + regex := regexp.MustCompile("[a-zA-Z0-9\\s]*(stdout|stderr):\\s(.*)") + match := regex.FindStringSubmatch(log) + + if len(match) > 2 && len(match[2]) > 0 { + fmt.Printf("%s\n", match[2]) Review comment: what do you think about using a utility function for the individual log strip logic ``` func stripTimestamp(log string) strippedLog string { regex := regexp.MustCompile("[a-zA-Z0-9\\s]*(stdout|stderr):\\s(.*)") match := regex.FindStringSubmatch(log) if len(match) > 2 && len(match[2]) > 0 { strippedLog = match[2] } else { strippedLog = log } return strippedLog } ``` then the print function would become ``` func printStrippedActivationLogs(logs []string) { for _, log := range logs { fmt.Printf("%s\n", stripTimestamp(log)) } } ``` the unit test would just validate the utility function. This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services
[GitHub] mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs
mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs URL: https://github.com/apache/incubator-openwhisk-cli/pull/292#discussion_r186152455 ## File path: commands/util.go ## @@ -283,7 +283,7 @@ func printFullActivationList(activations []whisk.Activation) { func printActivationLogs(logs []string) { for _, log := range logs { if Flags.activation.strip { - fmt.Printf("%s\n", log[39:]) + fmt.Printf("%s\n", log[strings.Index(log, ": ")+2:]) Review comment: https://play.golang.org/p/8zcL24npnPU This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services
[GitHub] mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs
mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs URL: https://github.com/apache/incubator-openwhisk-cli/pull/292#discussion_r186134887 ## File path: commands/util.go ## @@ -283,7 +283,7 @@ func printFullActivationList(activations []whisk.Activation) { func printActivationLogs(logs []string) { for _, log := range logs { if Flags.activation.strip { - fmt.Printf("%s\n", log[39:]) + fmt.Printf("%s\n", log[strings.Index(log, ": ")+2:]) Review comment: good catch.. yeah.. my code example was too compact ``` skip_index := strings.Index(log, "stdout: ") if skip_index == -1 { skip_index = strings.Index(log, "stdout: ") } fmt.Printf("%s\n", log[skip_index+8:]) ``` This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services
[GitHub] mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs
mdeuser commented on a change in pull request #292: Account for variable length timestamps when stripping logs URL: https://github.com/apache/incubator-openwhisk-cli/pull/292#discussion_r186078848 ## File path: commands/util.go ## @@ -283,7 +283,7 @@ func printFullActivationList(activations []whisk.Activation) { func printActivationLogs(logs []string) { for _, log := range logs { if Flags.activation.strip { - fmt.Printf("%s\n", log[39:]) + fmt.Printf("%s\n", log[strings.Index(log, ": ")+2:]) Review comment: or being completely timestamp format agnostic.. ready to ignore future timestamps with embedded ": " ``` log[strings.Index(log, "stdout: ")+strings.Index(log, "stderr: ")+9:] ``` This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services