diff --git a/filebeat/input/filestream/environment_test.go b/filebeat/input/filestream/environment_test.go index cc53d23a2147..1713a964c527 100644 --- a/filebeat/input/filestream/environment_test.go +++ b/filebeat/input/filestream/environment_test.go @@ -66,9 +66,7 @@ type registryEntry struct { } func newInputTestingEnvironment(t *testing.T) *inputTestingEnvironment { - if err := logp.DevelopmentSetup(logp.ToObserverOutput()); err != nil { - t.Fatalf("error setting up dev logging: %s", err) - } + logp.DevelopmentSetup(logp.ToObserverOutput()) t.Cleanup(func() { if t.Failed() { diff --git a/filebeat/input/filestream/fswatch_test.go b/filebeat/input/filestream/fswatch_test.go index ffa9b9c510e4..f9f58734360c 100644 --- a/filebeat/input/filestream/fswatch_test.go +++ b/filebeat/input/filestream/fswatch_test.go @@ -265,15 +265,14 @@ scanner: ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() - err := logp.DevelopmentSetup(logp.ToObserverOutput()) - require.NoError(t, err) + logp.DevelopmentSetup(logp.ToObserverOutput()) fw := createWatcherWithConfig(t, paths, cfgStr) go fw.Run(ctx) basename := "created.log" filename := filepath.Join(dir, basename) - err = os.WriteFile(filename, nil, 0777) + err := os.WriteFile(filename, nil, 0777) require.NoError(t, err) t.Run("issues a warning in logs", func(t *testing.T) { @@ -373,8 +372,7 @@ scanner: ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - err = logp.DevelopmentSetup(logp.ToObserverOutput()) - require.NoError(t, err) + logp.DevelopmentSetup(logp.ToObserverOutput()) fw := createWatcherWithConfig(t, paths, cfgStr) diff --git a/libbeat/autodiscover/autodiscover_test.go b/libbeat/autodiscover/autodiscover_test.go index 8d977a4c4d4a..93918180a928 100644 --- a/libbeat/autodiscover/autodiscover_test.go +++ b/libbeat/autodiscover/autodiscover_test.go @@ -733,9 +733,7 @@ func printDebugLogsOnFailure(t *testing.T) { // Use the following line to have the logs being printed // in real time. // logp.DevelopmentSetup(logp.WithLevel(logp.DebugLevel), logp.WithSelectors("*")) - if err := logp.DevelopmentSetup(logp.ToObserverOutput()); err != nil { - t.Fatalf("error setting up dev logging: %s", err) - } + logp.DevelopmentSetup(logp.ToObserverOutput()) t.Cleanup(func() { if t.Failed() { diff --git a/libbeat/cmd/instance/locks/lock_test.go b/libbeat/cmd/instance/locks/lock_test.go index 8e112a1b3f72..6e20f1263903 100644 --- a/libbeat/cmd/instance/locks/lock_test.go +++ b/libbeat/cmd/instance/locks/lock_test.go @@ -30,11 +30,8 @@ import ( ) func TestMain(m *testing.M) { - err := logp.DevelopmentSetup() - if err != nil { - fmt.Fprintf(os.Stderr, "error creating logger: %s\n", err) - os.Exit(1) - } + logp.DevelopmentSetup() + tmp, err := os.MkdirTemp("", "pidfile_test") defer os.RemoveAll(tmp) if err != nil { diff --git a/libbeat/publisher/queue/queuetest/log.go b/libbeat/publisher/queue/queuetest/log.go index 04b1a1185645..ef11e1ea563f 100644 --- a/libbeat/publisher/queue/queuetest/log.go +++ b/libbeat/publisher/queue/queuetest/log.go @@ -25,8 +25,6 @@ import ( "sync" "testing" - "gotest.tools/assert" - "github.com/elastic/elastic-agent-libs/logp" ) @@ -88,8 +86,7 @@ func withOptLogOutput(capture bool, fn func(*testing.T)) func(*testing.T) { if debug { level = logp.DebugLevel } - err = logp.DevelopmentSetup(logp.WithLevel(level)) - assert.NilError(t, err) + logp.DevelopmentSetup(logp.WithLevel(level)) fn(t) } } diff --git a/metricbeat/module/system/filesystem/filesystem_test.go b/metricbeat/module/system/filesystem/filesystem_test.go index 94c1a4151660..627cbf73f985 100644 --- a/metricbeat/module/system/filesystem/filesystem_test.go +++ b/metricbeat/module/system/filesystem/filesystem_test.go @@ -34,8 +34,7 @@ import ( func TestFetch(t *testing.T) { f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) events, errs := mbtest.ReportingFetchV2Error(f) - err := logp.DevelopmentSetup() - assert.NoError(t, err) + logp.DevelopmentSetup() assert.Empty(t, errs) if !assert.NotEmpty(t, events) { t.FailNow() diff --git a/metricbeat/module/system/process/process_test.go b/metricbeat/module/system/process/process_test.go index d9f57f2e3fee..5c1f59f7a3cb 100644 --- a/metricbeat/module/system/process/process_test.go +++ b/metricbeat/module/system/process/process_test.go @@ -24,7 +24,6 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing" _ "github.com/elastic/beats/v7/metricbeat/module/system" @@ -33,8 +32,7 @@ import ( ) func TestFetch(t *testing.T) { - err := logp.DevelopmentSetup() - require.NoError(t, err, "could not set the logger to DevelopmentSetup") + logp.DevelopmentSetup() f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) events, errs := mbtest.ReportingFetchV2Error(f) diff --git a/metricbeat/module/system/process_summary/process_summary_test.go b/metricbeat/module/system/process_summary/process_summary_test.go index eab6016a7884..7ec35634e434 100644 --- a/metricbeat/module/system/process_summary/process_summary_test.go +++ b/metricbeat/module/system/process_summary/process_summary_test.go @@ -42,8 +42,7 @@ func TestData(t *testing.T) { } func TestFetch(t *testing.T) { - err := logp.DevelopmentSetup() - require.NoError(t, err) + logp.DevelopmentSetup() f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) events, errs := mbtest.ReportingFetchV2Error(f) @@ -53,14 +52,13 @@ func TestFetch(t *testing.T) { t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), event.StringToPrint()) - _, err = event.GetValue("system.process.summary") + _, err := event.GetValue("system.process.summary") require.NoError(t, err) } func TestStateNames(t *testing.T) { - err := logp.DevelopmentSetup() - require.NoError(t, err) + logp.DevelopmentSetup() f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) events, errs := mbtest.ReportingFetchV2Error(f) diff --git a/packetbeat/protos/dns/dns_test.go b/packetbeat/protos/dns/dns_test.go index 567341ccc215..cbb2e201d8ab 100644 --- a/packetbeat/protos/dns/dns_test.go +++ b/packetbeat/protos/dns/dns_test.go @@ -97,7 +97,7 @@ func newDNS(store *eventStore, verbose bool) *dnsPlugin { if verbose { level = logp.DebugLevel } - _ = logp.DevelopmentSetup( + logp.DevelopmentSetup( logp.WithLevel(level), logp.WithSelectors("dns"), ) diff --git a/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go b/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go index cbbb6defc3ea..2b058de2beed 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go +++ b/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go @@ -76,10 +76,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { } func TestGetFilterForMetric(t *testing.T) { - if err := logp.DevelopmentSetup(logp.ToObserverOutput()); err != nil { - t.Fatalf("cannot initialise logger on development mode: %+v", err) - } - + logp.DevelopmentSetup(logp.ToObserverOutput()) var logger = logp.NewLogger("TestGetFilterForMetric") cases := []struct {