Skip to content

Commit

Permalink
Merge pull request #434 from olafure/logcli-skip-label-option
Browse files Browse the repository at this point in the history
Added a flag --no-labels to skip printing labels in the output from l…
  • Loading branch information
davkal authored Mar 29, 2019
2 parents bae599a + 4999be0 commit a7d41f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/logcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
since = queryCmd.Flag("since", "Lookback window.").Default("1h").Duration()
forward = queryCmd.Flag("forward", "Scan forwards through logs.").Default("false").Bool()
tail = queryCmd.Flag("tail", "Tail the logs").Short('t').Default("false").Bool()
noLabels = queryCmd.Flag("no-labels", "Do not print labels").Default("false").Bool()

labelsCmd = app.Command("labels", "Find values for a given label.")
labelName = labelsCmd.Arg("label", "The name of the label.").HintAction(listLabels).String()
Expand Down
8 changes: 7 additions & 1 deletion cmd/logcli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ func doQuery() {
for i.Next() {
ls := labelsCache(i.Labels())
ls = subtract(ls, common)

labels := ""
if !*noLabels {
labels = color.RedString(padLabel(ls, maxLabelsLen))
}

fmt.Println(
color.BlueString(i.Entry().Timestamp.Format(time.RFC3339)),
color.RedString(padLabel(ls, maxLabelsLen)),
labels,
strings.TrimSpace(i.Entry().Line),
)
}
Expand Down

0 comments on commit a7d41f0

Please sign in to comment.