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

logcli: add --to flag to specify latest RFC3339 time for query #776

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/logcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var (
regexpStr = queryCmd.Arg("regex", "").String()
limit = queryCmd.Flag("limit", "Limit on number of entries to print.").Default("30").Int()
since = queryCmd.Flag("since", "Lookback window.").Default("1h").Duration()
from = queryCmd.Flag("from", "Start looking for logs at this absolute time").String()
from = queryCmd.Flag("from", "Start looking for logs at this absolute time (inclusive)").String()
to = queryCmd.Flag("to", "Stop looking for logs at this absolute time (exclusive)").String()
forward = queryCmd.Flag("forward", "Scan forwards through logs.").Default("false").Bool()
tail = queryCmd.Flag("tail", "Tail the logs").Short('t').Default("false").Bool()
delayFor = queryCmd.Flag("delay-for", "Delay in tailing by number of seconds to accumulate logs").Default("0").Int()
Expand Down
10 changes: 9 additions & 1 deletion cmd/logcli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ func doQuery() {
var err error
start, err = time.Parse(time.RFC3339Nano, *from)
if err != nil {
log.Fatalf("error parsing date '%s': %s", *from, err)
log.Fatalf("error parsing --from date '%s': %s", *from, err)
}
}

if *to != "" {
var err error
end, err = time.Parse(time.RFC3339Nano, *to)
if err != nil {
log.Fatalf("error parsing --to date '%s': %s", *to, err)
}
}

Expand Down