Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use -10m as the default start time. #73

Open
a-h opened this issue Sep 14, 2022 · 0 comments
Open

Use -10m as the default start time. #73

a-h opened this issue Sep 14, 2022 · 0 comments

Comments

@a-h
Copy link

a-h commented Sep 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant