TylerBrock/saw

Use -10m as the default start time.

a-h opened this issue ยท 0 comments

a-h commented

I just spent a few minutes wondering why I wasn't seeing any log output. ๐Ÿ˜‚

I was using saw get /aws/lambda/<group_name> but forgot to add --start -10m to the end of the command.

The default is time.Now() so I wasn't seeing any logs.

currentTime := time.Now()
absoluteStartTime := currentTime
if c.Start != "" {
st, err := getTime(c.Start, currentTime)
if err == nil {
absoluteStartTime = st
}
}
input.SetStartTime(aws.TimeUnixMilli(absoluteStartTime))

AWS SAM [1] and Serverless Framework [2] both use -10m as their default for log retrieval, whereas saw uses the current time.

Seems like a straightforward change to set the empty string "" to -10m to match.

saw/cmd/get.go

Lines 42 to 51 in 77bbab2

func init() {
getCommand.Flags().StringVar(&getConfig.Prefix, "prefix", "", "log group prefix filter")
getCommand.Flags().StringVar(
&getConfig.Start,
"start",
"",
`start getting the logs from this point
Takes an absolute timestamp in RFC3339 format, or a relative time (eg. -2h).
Valid time units are "ns", "us" (or "ยตs"), "ms", "s", "m", "h".`,
)

What do you think? I've applied it in my fork, and am using it. Happy to PR.