Skip to content

Commit

Permalink
feat(logql): implement fmt.Stringer for Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed May 31, 2024
1 parent e32cd60 commit 96619b4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/logql/log_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package logql
import (
"fmt"
"regexp"
"strings"
)

// LogExpr is a log query expression.
Expand All @@ -20,6 +21,21 @@ type Selector struct {
Matchers []LabelMatcher
}

// String implements [fmt.Stringer].
func (s Selector) String() string {
var sb strings.Builder
sb.WriteByte('{')
for i, m := range s.Matchers {
if i != 0 {
sb.WriteByte(',')
}
// FIXME(tdakkota): suboptimal
sb.WriteString(m.String())
}
sb.WriteByte('}')
return sb.String()
}

// LabelMatcher is label matching predicate.
type LabelMatcher struct {
Label Label
Expand Down

0 comments on commit 96619b4

Please sign in to comment.