Skip to content

Commit

Permalink
Trim space from debug selectors in -d
Browse files Browse the repository at this point in the history
Using `-d "publish, processors"` wasn't working expected because `processors` included a leading space. Each selector is now trimmed.

Workarounds include using `-d publish -d processors` or `-d publish,processors`.
  • Loading branch information
andrewkroh committed Aug 4, 2018
1 parent b84e083 commit 03f7f86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
*Affecting all Beats*

- Fixed `add_host_metadata` not initializing correctly on Windows. {issue}7715[7715]
- Fixed `-d` CLI flag by trimming spaces from selectors. {pull}7864[7864]

*Auditbeat*

Expand Down
3 changes: 2 additions & 1 deletion libbeat/logp/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
golog "log"
"os"
"path/filepath"
"strings"
"sync/atomic"
"unsafe"

Expand Down Expand Up @@ -89,7 +90,7 @@ func Configure(cfg Config) error {
selectors := make(map[string]struct{}, len(cfg.Selectors))
if cfg.Level.Enabled(DebugLevel) && len(cfg.Selectors) > 0 {
for _, sel := range cfg.Selectors {
selectors[sel] = struct{}{}
selectors[strings.TrimSpace(sel)] = struct{}{}
}

// Default to all enabled if no selectors are specified.
Expand Down
4 changes: 3 additions & 1 deletion libbeat/logp/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ func TestLogger(t *testing.T) {
}

func TestLoggerSelectors(t *testing.T) {
if err := DevelopmentSetup(WithSelectors("good"), ToObserverOutput()); err != nil {
if err := DevelopmentSetup(WithSelectors("good", " padded "), ToObserverOutput()); err != nil {
t.Fatal(err)
}

assert.True(t, HasSelector("padded"))

good := NewLogger("good")
bad := NewLogger("bad")

Expand Down

0 comments on commit 03f7f86

Please sign in to comment.