diff --git a/cmd/launcher/extension.go b/cmd/launcher/extension.go index 356002d42..cdebe0c60 100644 --- a/cmd/launcher/extension.go +++ b/cmd/launcher/extension.go @@ -5,9 +5,7 @@ import ( "fmt" "log/slog" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/types" - "github.com/kolide/launcher/pkg/contexts/ctxlog" "github.com/kolide/launcher/pkg/osquery" "github.com/kolide/launcher/pkg/service" "github.com/kolide/launcher/pkg/traces" @@ -17,12 +15,10 @@ func createExtensionRuntime(ctx context.Context, k types.Knapsack, launcherClien ctx, span := traces.StartSpan(ctx) defer span.End() - logger := log.With(ctxlog.FromContext(ctx), "caller", log.DefaultCaller) slogger := k.Slogger().With("component", "osquery_extension_creator") // create the osquery extension extOpts := osquery.ExtensionOpts{ - Logger: logger, // Preserved only for temporary use in agent.SetupKeys LoggingInterval: k.LoggingInterval(), RunDifferentialQueriesImmediately: k.EnableInitialRunner(), } diff --git a/cmd/launcher/launcher.go b/cmd/launcher/launcher.go index 43f18d0b9..52d77d330 100644 --- a/cmd/launcher/launcher.go +++ b/cmd/launcher/launcher.go @@ -180,7 +180,7 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl return fmt.Errorf("write launcher pid to file: %w", err) } - stores, err := agentbbolt.MakeStores(ctx, logger, db) + stores, err := agentbbolt.MakeStores(ctx, slogger, db) if err != nil { return fmt.Errorf("failed to create stores: %w", err) } diff --git a/ee/agent/flags/flag_controller_test.go b/ee/agent/flags/flag_controller_test.go index 7fef8e124..8fcb22a6c 100644 --- a/ee/agent/flags/flag_controller_test.go +++ b/ee/agent/flags/flag_controller_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/flags/keys" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" @@ -34,9 +33,9 @@ func TestControllerBoolFlags(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) var value bool @@ -110,9 +109,9 @@ func TestControllerStringFlags(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) var value string @@ -234,9 +233,9 @@ func TestControllerDurationFlags(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) for i, valueToSet := range tt.valuesToSet { @@ -267,9 +266,9 @@ func TestControllerNotify(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) mockObserver := mocks.NewFlagsChangeObserver(t) @@ -305,9 +304,9 @@ func TestControllerUpdate(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) mockObserver := mocks.NewFlagsChangeObserver(t) @@ -346,9 +345,9 @@ func TestControllerOverride(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.AgentFlagsStore.String()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AgentFlagsStore.String()) require.NoError(t, err) - fc := NewFlagController(multislogger.New().Logger, store) + fc := NewFlagController(multislogger.NewNopLogger(), store) assert.NotNil(t, fc) mockObserver := mocks.NewFlagsChangeObserver(t) diff --git a/ee/agent/keys.go b/ee/agent/keys.go index 41a736839..23bb69637 100644 --- a/ee/agent/keys.go +++ b/ee/agent/keys.go @@ -1,13 +1,13 @@ package agent import ( + "context" "crypto" "fmt" + "log/slog" "runtime" "time" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" "github.com/kolide/launcher/ee/agent/keys" "github.com/kolide/launcher/ee/agent/types" "github.com/kolide/launcher/pkg/backoff" @@ -29,13 +29,13 @@ func LocalDbKeys() keyInt { return localDbKeys } -func SetupKeys(logger log.Logger, store types.GetterSetterDeleter) error { - logger = log.With(logger, "component", "agentkeys") +func SetupKeys(slogger *slog.Logger, store types.GetterSetterDeleter) error { + slogger = slogger.With("component", "agentkeys") var err error // Always setup a local key - localDbKeys, err = keys.SetupLocalDbKey(logger, store) + localDbKeys, err = keys.SetupLocalDbKey(slogger, store) if err != nil { return fmt.Errorf("setting up local db keys: %w", err) } @@ -46,7 +46,7 @@ func SetupKeys(logger log.Logger, store types.GetterSetterDeleter) error { } err = backoff.WaitFor(func() error { - hwKeys, err := setupHardwareKeys(logger, store) + hwKeys, err := setupHardwareKeys(slogger, store) if err != nil { return err } @@ -56,7 +56,10 @@ func SetupKeys(logger log.Logger, store types.GetterSetterDeleter) error { if err != nil { // Use of hardware keys is not fully implemented as of 2023-02-01, so log an error and move on - level.Info(logger).Log("msg", "failed to setting up hardware keys", "err", err) + slogger.Log(context.TODO(), slog.LevelInfo, + "failed setting up hardware keys", + "err", err, + ) } return nil @@ -104,7 +107,9 @@ func storeKeyData(store types.Setter, pri, pub []byte) error { // clearKeyData is used to clear the keys as part of error handling around new keys. It is not intended to be called // regularly, and since the path that calls it is around DB errors, it has no error handling. // nolint:unused -func clearKeyData(logger log.Logger, deleter types.Deleter) { - level.Info(logger).Log("msg", "Clearing keys") +func clearKeyData(slogger *slog.Logger, deleter types.Deleter) { + slogger.Log(context.TODO(), slog.LevelInfo, + "clearing keys", + ) _ = deleter.Delete([]byte(privateEccData), []byte(publicEccData)) } diff --git a/ee/agent/keys/local.go b/ee/agent/keys/local.go index 8b572cf6c..a581253db 100644 --- a/ee/agent/keys/local.go +++ b/ee/agent/keys/local.go @@ -1,12 +1,12 @@ package keys import ( + "context" "crypto/ecdsa" "crypto/x509" "fmt" + "log/slog" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" "github.com/kolide/krypto/pkg/echelper" "github.com/kolide/launcher/ee/agent/types" ) @@ -26,14 +26,21 @@ func (k dbKey) Type() string { return "local" } -func SetupLocalDbKey(logger log.Logger, store types.GetterSetter) (*dbKey, error) { +func SetupLocalDbKey(slogger *slog.Logger, store types.GetterSetter) (*dbKey, error) { if key, err := fetchKey(store); key != nil && err == nil { - level.Info(logger).Log("msg", "found local key in database") + slogger.Log(context.TODO(), slog.LevelInfo, + "found local key in database", + ) return &dbKey{key}, nil } else if err != nil { - level.Info(logger).Log("msg", "Failed to parse key, regenerating", "err", err) + slogger.Log(context.TODO(), slog.LevelInfo, + "failed to parse key, regenerating", + "err", err, + ) } else if key == nil { - level.Info(logger).Log("msg", "No key found, generating new key") + slogger.Log(context.TODO(), slog.LevelInfo, + "no key found, generating new key", + ) } // Time to regenerate! diff --git a/ee/agent/keys/local_test.go b/ee/agent/keys/local_test.go index 70848fca4..bf44c4af4 100644 --- a/ee/agent/keys/local_test.go +++ b/ee/agent/keys/local_test.go @@ -3,20 +3,20 @@ package keys import ( "testing" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/stretchr/testify/require" ) func TestSetupLocalDbKey(t *testing.T) { t.Parallel() - logger := log.NewNopLogger() - store, err := storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String()) + slogger := multislogger.NewNopLogger() + store, err := storageci.NewStore(t, slogger, storage.ConfigStore.String()) require.NoError(t, err) - key, err := SetupLocalDbKey(logger, store) + key, err := SetupLocalDbKey(slogger, store) require.NoError(t, err) require.NotNil(t, key) @@ -24,7 +24,7 @@ func TestSetupLocalDbKey(t *testing.T) { require.NotNil(t, key.Public()) // If we call this _again_ do we get the same key back? - key2, err := SetupLocalDbKey(logger, store) + key2, err := SetupLocalDbKey(slogger, store) require.NoError(t, err) require.Equal(t, key.Public(), key2.Public()) } diff --git a/ee/agent/keys_darwin.go b/ee/agent/keys_darwin.go index 6b8ab40d6..1f8fd4ecb 100644 --- a/ee/agent/keys_darwin.go +++ b/ee/agent/keys_darwin.go @@ -5,13 +5,13 @@ package agent import ( "errors" + "log/slog" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/types" ) // nolint:unused -func setupHardwareKeys(logger log.Logger, store types.GetterSetterDeleter) (keyInt, error) { +func setupHardwareKeys(slogger *slog.Logger, store types.GetterSetterDeleter) (keyInt, error) { // We're seeing issues where launcher hangs (and does not complete startup) on the // Sonoma Beta 2 release when trying to interact with the secure enclave below, on // CreateKey. Since we don't expect this to work at the moment anyway, we are diff --git a/ee/agent/keys_tpm.go b/ee/agent/keys_tpm.go index 10b437b65..330cb5a8f 100644 --- a/ee/agent/keys_tpm.go +++ b/ee/agent/keys_tpm.go @@ -4,33 +4,35 @@ package agent import ( + "context" "fmt" + "log/slog" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" "github.com/kolide/krypto/pkg/tpm" "github.com/kolide/launcher/ee/agent/types" ) // nolint:unused -func setupHardwareKeys(logger log.Logger, store types.GetterSetterDeleter) (keyInt, error) { +func setupHardwareKeys(slogger *slog.Logger, store types.GetterSetterDeleter) (keyInt, error) { priData, pubData, err := fetchKeyData(store) if err != nil { return nil, err } if pubData == nil || priData == nil { - level.Info(logger).Log("msg", "Generating new keys") + slogger.Log(context.TODO(), slog.LevelInfo, + "generating new keys", + ) var err error priData, pubData, err = tpm.CreateKey() if err != nil { - clearKeyData(logger, store) + clearKeyData(slogger, store) return nil, fmt.Errorf("creating key: %w", err) } if err := storeKeyData(store, priData, pubData); err != nil { - clearKeyData(logger, store) + clearKeyData(slogger, store) return nil, fmt.Errorf("storing key: %w", err) } } diff --git a/ee/agent/reset_test.go b/ee/agent/reset_test.go index 0757b3f96..34934c3f0 100644 --- a/ee/agent/reset_test.go +++ b/ee/agent/reset_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/golang-jwt/jwt/v5" "github.com/kolide/kit/fsutil" "github.com/kolide/krypto/pkg/echelper" @@ -252,15 +251,17 @@ func TestDetectAndRemediateHardwareChange(t *testing.T) { // the tests and they will continue to validate expected behavior. tt.expectDatabaseWipe = false + slogger := multislogger.NewNopLogger() + // Set up dependencies: data store for hardware-identifying data - testHostDataStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.PersistentHostDataStore.String()) + testHostDataStore, err := storageci.NewStore(t, slogger, storage.PersistentHostDataStore.String()) require.NoError(t, err, "could not create test host data store") mockKnapsack := typesmocks.NewKnapsack(t) mockKnapsack.On("PersistentHostDataStore").Return(testHostDataStore) - testConfigStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String()) + testConfigStore, err := storageci.NewStore(t, slogger, storage.ConfigStore.String()) require.NoError(t, err, "could not create test config store") mockKnapsack.On("ConfigStore").Return(testConfigStore).Maybe() - testServerProvidedDataStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.ServerProvidedDataStore.String()) + testServerProvidedDataStore, err := storageci.NewStore(t, slogger, storage.ServerProvidedDataStore.String()) require.NoError(t, err, "could not create test server provided data store") mockKnapsack.On("ServerProvidedDataStore").Return(testServerProvidedDataStore).Maybe() mockKnapsack.On("Stores").Return(map[storage.Store]types.KVStore{ @@ -270,7 +271,6 @@ func TestDetectAndRemediateHardwareChange(t *testing.T) { }).Maybe() // Set up logger - slogger := multislogger.New().Logger mockKnapsack.On("Slogger").Return(slogger) // Set up dependencies: ensure that retrieved hardware data matches expectations @@ -431,15 +431,17 @@ func TestDetectAndRemediateHardwareChange_SavesDataOverMultipleResets(t *testing t.Skip("un-skip test once we decide to reset the database on hardware change") + slogger := multislogger.NewNopLogger() + // Set up dependencies: data store for hardware-identifying data - testHostDataStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.PersistentHostDataStore.String()) + testHostDataStore, err := storageci.NewStore(t, slogger, storage.PersistentHostDataStore.String()) require.NoError(t, err, "could not create test host data store") mockKnapsack := typesmocks.NewKnapsack(t) mockKnapsack.On("PersistentHostDataStore").Return(testHostDataStore) - testConfigStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String()) + testConfigStore, err := storageci.NewStore(t, slogger, storage.ConfigStore.String()) require.NoError(t, err, "could not create test config store") mockKnapsack.On("ConfigStore").Return(testConfigStore) - testServerProvidedDataStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.ServerProvidedDataStore.String()) + testServerProvidedDataStore, err := storageci.NewStore(t, slogger, storage.ServerProvidedDataStore.String()) require.NoError(t, err, "could not create test server provided data store") mockKnapsack.On("ServerProvidedDataStore").Return(testServerProvidedDataStore) mockKnapsack.On("Stores").Return(map[storage.Store]types.KVStore{ @@ -449,7 +451,6 @@ func TestDetectAndRemediateHardwareChange_SavesDataOverMultipleResets(t *testing }) // Set up logger - slogger := multislogger.New().Logger mockKnapsack.On("Slogger").Return(slogger) // Set up dependencies: ensure that retrieved hardware data matches expectations diff --git a/ee/agent/storage/bbolt/keyvalue_store_bbolt.go b/ee/agent/storage/bbolt/keyvalue_store_bbolt.go index bf61c0528..b9005fdb7 100644 --- a/ee/agent/storage/bbolt/keyvalue_store_bbolt.go +++ b/ee/agent/storage/bbolt/keyvalue_store_bbolt.go @@ -1,10 +1,10 @@ package agentbbolt import ( + "context" "fmt" + "log/slog" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" "go.etcd.io/bbolt" ) @@ -28,12 +28,12 @@ func NewNoBucketError(bucketName string) NoBucketError { } type bboltKeyValueStore struct { - logger log.Logger + slogger *slog.Logger db *bbolt.DB bucketName string } -func NewStore(logger log.Logger, db *bbolt.DB, bucketName string) (*bboltKeyValueStore, error) { +func NewStore(slogger *slog.Logger, db *bbolt.DB, bucketName string) (*bboltKeyValueStore, error) { err := db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists([]byte(bucketName)) if err != nil { @@ -48,7 +48,7 @@ func NewStore(logger log.Logger, db *bbolt.DB, bucketName string) (*bboltKeyValu } m := &bboltKeyValueStore{ - logger: log.With(logger, "bucket", bucketName), + slogger: slogger.With("bucket", bucketName), db: db, bucketName: bucketName, } @@ -170,8 +170,8 @@ func (s *bboltKeyValueStore) Update(kvPairs map[string]string) ([]string, error) for key, value := range kvPairs { if err := b.Put([]byte(key), []byte(value)); err != nil { // Log errors but continue processing the remaining key-values - level.Error(s.logger).Log( - "msg", "failed to store key-value in bucket", + s.slogger.Log(context.TODO(), slog.LevelError, + "failed to store key-value in bucket", "key", key, "err", err, ) @@ -205,8 +205,8 @@ func (s *bboltKeyValueStore) Update(kvPairs map[string]string) ([]string, error) // Key exists in the bucket but not in kvPairs, delete it if err := b.Delete(key); err != nil { // Log errors but ignore the failure - level.Error(s.logger).Log( - "msg", "failed to remove key from bucket", + s.slogger.Log(context.TODO(), slog.LevelError, + "failed to remove key from bucket", "key", key, "err", err, ) diff --git a/ee/agent/storage/bbolt/stores_bbolt.go b/ee/agent/storage/bbolt/stores_bbolt.go index 766121e8b..97d6a0e5d 100644 --- a/ee/agent/storage/bbolt/stores_bbolt.go +++ b/ee/agent/storage/bbolt/stores_bbolt.go @@ -3,8 +3,7 @@ package agentbbolt import ( "context" "fmt" - - "github.com/go-kit/kit/log" + "log/slog" "github.com/kolide/launcher/ee/agent/storage" "github.com/kolide/launcher/ee/agent/types" @@ -13,7 +12,7 @@ import ( ) // MakeStores creates all the KVStores used by launcher -func MakeStores(ctx context.Context, logger log.Logger, db *bbolt.DB) (map[storage.Store]types.KVStore, error) { +func MakeStores(ctx context.Context, slogger *slog.Logger, db *bbolt.DB) (map[storage.Store]types.KVStore, error) { _, span := traces.StartSpan(ctx) defer span.End() @@ -36,7 +35,7 @@ func MakeStores(ctx context.Context, logger log.Logger, db *bbolt.DB) (map[stora } for _, storeName := range storeNames { - store, err := NewStore(logger, db, storeName.String()) + store, err := NewStore(slogger, db, storeName.String()) if err != nil { return nil, fmt.Errorf("failed to create '%s' KVStore: %w", storeName, err) } diff --git a/ee/agent/storage/ci/keyvalue_store_ci.go b/ee/agent/storage/ci/keyvalue_store_ci.go index d099a1f80..a3a51932d 100644 --- a/ee/agent/storage/ci/keyvalue_store_ci.go +++ b/ee/agent/storage/ci/keyvalue_store_ci.go @@ -2,11 +2,11 @@ package storageci import ( "fmt" + "log/slog" "os" "path/filepath" "testing" - "github.com/go-kit/kit/log" agentbbolt "github.com/kolide/launcher/ee/agent/storage/bbolt" "github.com/kolide/launcher/ee/agent/storage/inmemory" "github.com/kolide/launcher/ee/agent/types" @@ -18,12 +18,12 @@ const ( dbTestFileName = "test.db" ) -func NewStore(t *testing.T, logger log.Logger, bucketName string) (types.KVStore, error) { +func NewStore(t *testing.T, slogger *slog.Logger, bucketName string) (types.KVStore, error) { if os.Getenv("CI") == "true" { return inmemory.NewStore(), nil } - return agentbbolt.NewStore(logger, SetupDB(t), bucketName) + return agentbbolt.NewStore(slogger, SetupDB(t), bucketName) } // SetupDB is used for creating bbolt databases for testing diff --git a/ee/agent/storage/ci/keyvalue_store_test.go b/ee/agent/storage/ci/keyvalue_store_test.go index ef4abb5f3..f777a6d77 100644 --- a/ee/agent/storage/ci/keyvalue_store_test.go +++ b/ee/agent/storage/ci/keyvalue_store_test.go @@ -6,18 +6,17 @@ import ( "sync" "testing" - "github.com/go-kit/kit/log" agentbbolt "github.com/kolide/launcher/ee/agent/storage/bbolt" "github.com/kolide/launcher/ee/agent/storage/inmemory" "github.com/kolide/launcher/ee/agent/types" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func getStores(t *testing.T) []types.KVStore { - logger := log.NewNopLogger() db := SetupDB(t) - bboltStore, err := agentbbolt.NewStore(logger, db, "test_bucket") + bboltStore, err := agentbbolt.NewStore(multislogger.NewNopLogger(), db, "test_bucket") require.NoError(t, err) stores := []types.KVStore{ diff --git a/ee/agent/storage/ci/stores_ci.go b/ee/agent/storage/ci/stores_ci.go index 2aabc76f2..c6b0d9061 100644 --- a/ee/agent/storage/ci/stores_ci.go +++ b/ee/agent/storage/ci/stores_ci.go @@ -2,10 +2,10 @@ package storageci import ( "fmt" + "log/slog" "os" "testing" - "github.com/go-kit/kit/log" "go.etcd.io/bbolt" "github.com/kolide/launcher/ee/agent/storage" @@ -15,7 +15,7 @@ import ( ) // MakeStores creates all the KVStores used by launcher -func MakeStores(t *testing.T, logger log.Logger, db *bbolt.DB) (map[storage.Store]types.KVStore, error) { +func MakeStores(t *testing.T, slogger *slog.Logger, db *bbolt.DB) (map[storage.Store]types.KVStore, error) { var storeNames = []storage.Store{ storage.AgentFlagsStore, storage.AutoupdateErrorsStore, @@ -35,7 +35,7 @@ func MakeStores(t *testing.T, logger log.Logger, db *bbolt.DB) (map[storage.Stor return makeInMemoryStores(t, storeNames), nil } - return makeBboltStores(t, logger, db, storeNames) + return makeBboltStores(t, slogger, db, storeNames) } func makeInMemoryStores(t *testing.T, storeNames []storage.Store) map[storage.Store]types.KVStore { @@ -48,11 +48,11 @@ func makeInMemoryStores(t *testing.T, storeNames []storage.Store) map[storage.St return stores } -func makeBboltStores(t *testing.T, logger log.Logger, db *bbolt.DB, storeNames []storage.Store) (map[storage.Store]types.KVStore, error) { +func makeBboltStores(t *testing.T, slogger *slog.Logger, db *bbolt.DB, storeNames []storage.Store) (map[storage.Store]types.KVStore, error) { stores := make(map[storage.Store]types.KVStore) for _, storeName := range storeNames { - store, err := agentbbolt.NewStore(logger, db, storeName.String()) + store, err := agentbbolt.NewStore(slogger, db, storeName.String()) if err != nil { return nil, fmt.Errorf("failed to create '%s' KVStore: %w", storeName, err) } diff --git a/ee/control/actionqueue/actionqueue_test.go b/ee/control/actionqueue/actionqueue_test.go index a8e355701..25e115109 100644 --- a/ee/control/actionqueue/actionqueue_test.go +++ b/ee/control/actionqueue/actionqueue_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/kit/ulid" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" @@ -54,7 +53,7 @@ func TestActionQueue_HandlesDuplicates(t *testing.T) { mockActor.On("Do", mock.Anything).Return(nil).Once() mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) actionqueue := New(mockKnapsack) actionqueue.RegisterActor(testActorType, mockActor) @@ -95,7 +94,7 @@ func TestActionQueue_ChecksOldNotificationStore(t *testing.T) { mockActor.On("Do", mock.Anything).Return(nil).Once() mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) actionqueue := New(mockKnapsack, WithOldNotificationsStore(oldNotificationStore)) @@ -153,7 +152,7 @@ func TestActionQueue_HandlesMultipleActorTypes(t *testing.T) { anotherMockActor.On("Do", mock.Anything).Return(nil).Twice() mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) actionqueue := New(mockKnapsack) @@ -190,7 +189,7 @@ func TestActionQueue_HandlesDuplicatesWhenFirstActionCouldNotBeSent(t *testing.T mockActor.On("Do", mock.Anything).Return(nil).NotBefore(errorCall).Once() mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) // Call Do and assert our expectations about completed actions actionqueue := New(mockKnapsack) @@ -268,7 +267,7 @@ func TestStopCleanup_Multiple(t *testing.T) { mockActor := mocks.NewActor(t) store := setupStorage(t) mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) actionQueue := New( mockKnapsack, WithStore(store), @@ -346,7 +345,7 @@ func TestActionQueue_HandlesMalformedActions(t *testing.T) { mockActioner.On("Do", bytes.NewReader(goodActionRaw)).Return(nil) mockKnapsack := typesmocks.NewKnapsack(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) actionqueue := New(mockKnapsack) actionqueue.RegisterActor(testActorType, mockActioner) @@ -354,7 +353,7 @@ func TestActionQueue_HandlesMalformedActions(t *testing.T) { } func setupStorage(t *testing.T) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.ControlServerActionsStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.ControlServerActionsStore.String()) require.NoError(t, err) return s } diff --git a/ee/debug/shipper/shipper_test.go b/ee/debug/shipper/shipper_test.go index afc319c60..49ea7e7b7 100644 --- a/ee/debug/shipper/shipper_test.go +++ b/ee/debug/shipper/shipper_test.go @@ -8,11 +8,11 @@ import ( "net/http/httptest" "testing" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent" "github.com/kolide/launcher/ee/agent/storage/inmemory" typesMocks "github.com/kolide/launcher/ee/agent/types/mocks" "github.com/kolide/launcher/ee/control" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -56,7 +56,7 @@ func TestShip(t *testing.T) { //nolint:paralleltest name: "happy path with signing keys and enroll secret", mockKnapsack: func(t *testing.T) *typesMocks.Knapsack { configStore := inmemory.NewStore() - agent.SetupKeys(log.NewNopLogger(), configStore) + agent.SetupKeys(multislogger.NewNopLogger(), configStore) k := typesMocks.NewKnapsack(t) k.On("EnrollSecret").Return("enroll_secret_value") diff --git a/ee/localserver/request-controlservice_test.go b/ee/localserver/request-controlservice_test.go index 8ba4af15b..1143a376b 100644 --- a/ee/localserver/request-controlservice_test.go +++ b/ee/localserver/request-controlservice_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" "github.com/kolide/launcher/ee/agent/types" @@ -20,11 +19,13 @@ import ( func Test_localServer_requestAccelerateControlFunc(t *testing.T) { t.Parallel() + slogger := multislogger.NewNopLogger() + defaultMockKnapsack := func() types.Knapsack { m := mocks.NewKnapsack(t) - m.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + m.On("ConfigStore").Return(storageci.NewStore(t, slogger, storage.ConfigStore.String())) m.On("KolideServerURL").Return("localhost") - m.On("Slogger").Return(multislogger.New().Logger) + m.On("Slogger").Return(slogger) return m } @@ -46,10 +47,10 @@ func Test_localServer_requestAccelerateControlFunc(t *testing.T) { expectedInterval: 250 * time.Millisecond, mockKnapsack: func() types.Knapsack { m := mocks.NewKnapsack(t) - m.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + m.On("ConfigStore").Return(storageci.NewStore(t, slogger, storage.ConfigStore.String())) m.On("KolideServerURL").Return("localhost") m.On("SetControlRequestIntervalOverride", 250*time.Millisecond, 1*time.Second) - m.On("Slogger").Return(multislogger.New().Logger) + m.On("Slogger").Return(slogger) return m }, }, diff --git a/ee/localserver/request-id_test.go b/ee/localserver/request-id_test.go index 57c76a162..fe5c9fecc 100644 --- a/ee/localserver/request-id_test.go +++ b/ee/localserver/request-id_test.go @@ -10,11 +10,11 @@ import ( "strings" "testing" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" "github.com/kolide/launcher/ee/agent/types" typesMocks "github.com/kolide/launcher/ee/agent/types/mocks" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/kolide/launcher/pkg/osquery" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +24,7 @@ func Test_localServer_requestIdHandler(t *testing.T) { t.Parallel() mockKnapsack := typesMocks.NewKnapsack(t) - mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) mockKnapsack.On("KolideServerURL").Return("localhost") var logBytes bytes.Buffer diff --git a/ee/localserver/request-query_test.go b/ee/localserver/request-query_test.go index 51eb4f211..6266301e8 100644 --- a/ee/localserver/request-query_test.go +++ b/ee/localserver/request-query_test.go @@ -9,7 +9,6 @@ import ( "net/http/httptest" "testing" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" typesMocks "github.com/kolide/launcher/ee/agent/types/mocks" @@ -56,9 +55,9 @@ func Test_localServer_requestQueryHandler(t *testing.T) { t.Parallel() mockKnapsack := typesMocks.NewKnapsack(t) - mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) mockKnapsack.On("KolideServerURL").Return("localhost") - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) //go:generate mockery --name Querier // https://github.com/vektra/mockery <-- cli tool to generate mocks for usage with testify @@ -222,9 +221,9 @@ func Test_localServer_requestRunScheduledQueryHandler(t *testing.T) { t.Parallel() mockKnapsack := typesMocks.NewKnapsack(t) - mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + mockKnapsack.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) mockKnapsack.On("KolideServerURL").Return("localhost") - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) // set up mock querier mockQuerier := mocks.NewQuerier(t) diff --git a/ee/localserver/server_test.go b/ee/localserver/server_test.go index 58294a1fd..83dfd5cdf 100644 --- a/ee/localserver/server_test.go +++ b/ee/localserver/server_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" typesmocks "github.com/kolide/launcher/ee/agent/types/mocks" @@ -20,14 +19,16 @@ import ( func TestInterrupt_Multiple(t *testing.T) { t.Parallel() - c, err := storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String()) + slogger := multislogger.NewNopLogger() + + c, err := storageci.NewStore(t, slogger, storage.ConfigStore.String()) require.NoError(t, err) require.NoError(t, osquery.SetupLauncherKeys(c)) k := typesmocks.NewKnapsack(t) k.On("KolideServerURL").Return("localserver") k.On("ConfigStore").Return(c) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(slogger) // Override the poll and recalculate interval for the test so we can be sure that the async workers // do run, but then stop running on shutdown diff --git a/ee/tables/launcher_db/launcher_db_test.go b/ee/tables/launcher_db/launcher_db_test.go index d061a31d9..5c8f0e6ae 100644 --- a/ee/tables/launcher_db/launcher_db_test.go +++ b/ee/tables/launcher_db/launcher_db_test.go @@ -3,10 +3,10 @@ package launcher_db import ( "testing" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" "github.com/kolide/launcher/ee/agent/types" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -72,7 +72,7 @@ func Test_generateLauncherDbTable(t *testing.T) { } func setupStorage(t *testing.T, values map[string]string) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.ServerProvidedDataStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.ServerProvidedDataStore.String()) require.NoError(t, err) // add the values to the bucket diff --git a/ee/tuf/autoupdate_test.go b/ee/tuf/autoupdate_test.go index 612761fe0..eae1b17e3 100644 --- a/ee/tuf/autoupdate_test.go +++ b/ee/tuf/autoupdate_test.go @@ -18,7 +18,6 @@ import ( "time" "github.com/Masterminds/semver" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" "github.com/kolide/launcher/ee/agent/types" @@ -41,7 +40,7 @@ func TestNewTufAutoupdater(t *testing.T) { mockKnapsack.On("TufServerURL").Return("https://example.com") mockKnapsack.On("UpdateDirectory").Return("") mockKnapsack.On("MirrorServerURL").Return("https://example.com") - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) _, err := NewTufAutoupdater(context.TODO(), mockKnapsack, http.DefaultClient, http.DefaultClient, newMockQuerier(t)) require.NoError(t, err, "could not initialize new TUF autoupdater") @@ -393,7 +392,7 @@ func TestInterrupt_Multiple(t *testing.T) { mockKnapsack.On("TufServerURL").Return(testMetadataServer.URL) mockKnapsack.On("UpdateDirectory").Return("") mockKnapsack.On("MirrorServerURL").Return("https://example.com") - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) mockQuerier := newMockQuerier(t) // Set up autoupdater @@ -519,7 +518,7 @@ func TestDo(t *testing.T) { mockKnapsack.On("MirrorServerURL").Return("https://example.com") mockKnapsack.On("LocalDevelopmentPath").Return("").Maybe() mockQuerier := newMockQuerier(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) // Set up autoupdater autoupdater, err := NewTufAutoupdater(context.TODO(), mockKnapsack, http.DefaultClient, http.DefaultClient, mockQuerier, WithOsqueryRestart(func() error { return nil })) @@ -585,7 +584,7 @@ func TestDo_HandlesSimultaneousUpdates(t *testing.T) { mockKnapsack.On("MirrorServerURL").Return("https://example.com") mockKnapsack.On("LocalDevelopmentPath").Return("") mockQuerier := newMockQuerier(t) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) // Set up autoupdater autoupdater, err := NewTufAutoupdater(context.TODO(), mockKnapsack, http.DefaultClient, http.DefaultClient, mockQuerier, WithOsqueryRestart(func() error { return nil })) @@ -646,7 +645,7 @@ func Test_currentRunningVersion_launcher_errorWhenVersionIsNotSet(t *testing.T) mockQuerier := newMockQuerier(t) autoupdater := &TufAutoupdater{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), osquerier: mockQuerier, } @@ -662,7 +661,7 @@ func Test_currentRunningVersion_osqueryd(t *testing.T) { mockQuerier := newMockQuerier(t) autoupdater := &TufAutoupdater{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), osquerier: mockQuerier, } @@ -681,7 +680,7 @@ func Test_currentRunningVersion_osqueryd_handlesQueryError(t *testing.T) { mockQuerier := newMockQuerier(t) autoupdater := &TufAutoupdater{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), osquerier: mockQuerier, osquerierRetryInterval: 1 * time.Millisecond, } @@ -711,7 +710,7 @@ func Test_storeError(t *testing.T) { mockKnapsack.On("TufServerURL").Return(testTufServer.URL) mockKnapsack.On("UpdateDirectory").Return("") mockKnapsack.On("MirrorServerURL").Return("https://example.com") - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) mockQuerier := newMockQuerier(t) autoupdater, err := NewTufAutoupdater(context.TODO(), mockKnapsack, http.DefaultClient, http.DefaultClient, mockQuerier) @@ -758,7 +757,7 @@ func Test_cleanUpOldErrors(t *testing.T) { autoupdater := &TufAutoupdater{ store: setupStorage(t), - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), } // Add one legitimate timestamp @@ -797,7 +796,7 @@ func Test_cleanUpOldErrors(t *testing.T) { } func setupStorage(t *testing.T) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.AutoupdateErrorsStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.AutoupdateErrorsStore.String()) require.NoError(t, err) return s } diff --git a/ee/uninstall/uninstall_test.go b/ee/uninstall/uninstall_test.go index 322639576..7bc772b97 100644 --- a/ee/uninstall/uninstall_test.go +++ b/ee/uninstall/uninstall_test.go @@ -7,7 +7,6 @@ import ( "path/filepath" "testing" - "github.com/go-kit/kit/log" "github.com/kolide/kit/ulid" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" @@ -45,7 +44,7 @@ func TestUninstall(t *testing.T) { // create 3 stores with 3 items each stores := map[storage.Store]types.KVStore{} for i := 0; i < 3; i++ { - store, err := storageci.NewStore(t, log.NewNopLogger(), ulid.New()) + store, err := storageci.NewStore(t, multislogger.NewNopLogger(), ulid.New()) require.NoError(t, err) for j := 0; j < 3; j++ { @@ -72,7 +71,7 @@ func TestUninstall(t *testing.T) { k := mocks.NewKnapsack(t) k.On("Stores").Return(stores) k.On("EnrollSecretPath").Return(enrollSecretPath) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) Uninstall(context.TODO(), k, false) diff --git a/pkg/log/logshipper/logshipper_test.go b/pkg/log/logshipper/logshipper_test.go index 13da8afb7..c90755c16 100644 --- a/pkg/log/logshipper/logshipper_test.go +++ b/pkg/log/logshipper/logshipper_test.go @@ -58,7 +58,7 @@ func TestLogShipper(t *testing.T) { // no device identifying attributes logIngestUrl := "https://example.com" knapsack.On("LogIngestServerURL").Return(logIngestUrl).Times(4) - knapsack.On("ServerProvidedDataStore").Return(storageci.NewStore(t, log.NewNopLogger(), "test")).Once() + knapsack.On("ServerProvidedDataStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), "test")).Once() ls.Ping() require.False(t, ls.isShippingStarted, "shipping should not have stared since there are no device identifying attributes") require.Equal(t, authToken, ls.sender.authtoken) @@ -103,7 +103,7 @@ func TestLogShipper(t *testing.T) { // update shipping level knapsack.On("LogShippingLevel").Return("debug") - knapsack.On("Slogger").Return(multislogger.New().Logger) + knapsack.On("Slogger").Return(multislogger.NewNopLogger()) ls.Ping() require.Equal(t, slog.LevelDebug.Level(), ls.slogLevel.Level(), "log shipper should set to debug") require.Equal(t, authToken, ls.sender.authtoken) @@ -137,7 +137,7 @@ func TestStop_Multiple(t *testing.T) { knapsack.On("LogIngestServerURL").Return(endpoint).Times(1) knapsack.On("ServerProvidedDataStore").Return(tokenStore) knapsack.On("LogShippingLevel").Return("debug") - knapsack.On("Slogger").Return(multislogger.New().Logger) + knapsack.On("Slogger").Return(multislogger.NewNopLogger()) knapsack.On("RegisterChangeObserver", mock.Anything, keys.LogShippingLevel, keys.LogIngestServerURL) ls := New(knapsack, log.NewNopLogger()) @@ -192,7 +192,7 @@ func TestStopWithoutRun(t *testing.T) { knapsack.On("LogIngestServerURL").Return(endpoint).Times(1) knapsack.On("ServerProvidedDataStore").Return(tokenStore) knapsack.On("LogShippingLevel").Return("debug") - knapsack.On("Slogger").Return(multislogger.New().Logger) + knapsack.On("Slogger").Return(multislogger.NewNopLogger()) knapsack.On("RegisterChangeObserver", mock.Anything, keys.LogShippingLevel, keys.LogIngestServerURL) ls := New(knapsack, log.NewNopLogger()) @@ -208,7 +208,7 @@ var deviceIdentifyingAttributes = map[string]string{ } func testKVStore(t *testing.T, name string) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), name) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), name) for k, v := range deviceIdentifyingAttributes { s.Set([]byte(k), []byte(v)) diff --git a/pkg/log/multislogger/multislogger.go b/pkg/log/multislogger/multislogger.go index 0025f0a63..1fa5a2abe 100644 --- a/pkg/log/multislogger/multislogger.go +++ b/pkg/log/multislogger/multislogger.go @@ -50,6 +50,11 @@ func New(h ...slog.Handler) *MultiSlogger { return ms } +// NewNopLogger returns a slogger with no handlers, discarding all logs. +func NewNopLogger() *slog.Logger { + return New().Logger +} + // AddHandler adds a handler to the multislogger, this creates a branch new // slog.Logger under the the hood, and overwrites old Logger memory address, // this means any attributes added with Logger.With will be lost diff --git a/pkg/osquery/extension.go b/pkg/osquery/extension.go index 983313cd1..abe2e5c70 100644 --- a/pkg/osquery/extension.go +++ b/pkg/osquery/extension.go @@ -13,7 +13,6 @@ import ( "sync" "time" - "github.com/go-kit/kit/log" "github.com/google/uuid" "github.com/kolide/launcher/ee/agent" "github.com/kolide/launcher/ee/agent/storage" @@ -86,12 +85,6 @@ type ExtensionOpts struct { // default it will be a normal realtime clock, but a mock clock can be // passed with clock.NewMockClock() for testing purposes. Clock clock.Clock - // Logger is the logger that the extension should use. This is for - // logging about the launcher, and not for logging osquery results. - // Logging should be done through the knapsack slogger -- this is - // preserved only for temporary use in call to agent.SetupKeys until - // we move that over to using the slogger too. - Logger log.Logger // MaxBufferedLogs is the maximum number of logs to buffer before // purging oldest logs (applies per log type). MaxBufferedLogs int @@ -121,10 +114,6 @@ func NewExtension(ctx context.Context, client service.KolideService, k types.Kna opts.Clock = clock.DefaultClock{} } - if opts.Logger == nil { - opts.Logger = log.NewNopLogger() - } - if opts.MaxBufferedLogs == 0 { opts.MaxBufferedLogs = defaultMaxBufferedLogs } @@ -135,7 +124,7 @@ func NewExtension(ctx context.Context, client service.KolideService, k types.Kna return nil, fmt.Errorf("setting up initial launcher keys: %w", err) } - if err := agent.SetupKeys(opts.Logger, configStore); err != nil { + if err := agent.SetupKeys(slogger, configStore); err != nil { return nil, fmt.Errorf("setting up agent keys: %w", err) } diff --git a/pkg/osquery/extension_test.go b/pkg/osquery/extension_test.go index 7f0901548..a9fa0ed98 100644 --- a/pkg/osquery/extension_test.go +++ b/pkg/osquery/extension_test.go @@ -16,7 +16,6 @@ import ( "testing/quick" "time" - "github.com/go-kit/kit/log" "github.com/kolide/kit/testutil" "github.com/kolide/launcher/ee/agent/storage" agentbbolt "github.com/kolide/launcher/ee/agent/storage/bbolt" @@ -56,8 +55,8 @@ func makeKnapsack(t *testing.T, db *bbolt.DB) types.Knapsack { m := mocks.NewKnapsack(t) m.On("OsquerydPath").Maybe().Return("") m.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - m.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) - m.On("Slogger").Return(multislogger.New().Logger) + m.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) + m.On("Slogger").Return(multislogger.NewNopLogger()) m.On("ReadEnrollSecret").Maybe().Return("enroll_secret", nil) return m } @@ -66,8 +65,8 @@ func TestNewExtensionEmptyEnrollSecret(t *testing.T) { m := mocks.NewKnapsack(t) m.On("OsquerydPath").Maybe().Return("") m.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - m.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) - m.On("Slogger").Return(multislogger.New().Logger) + m.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) + m.On("Slogger").Return(multislogger.NewNopLogger()) m.On("ReadEnrollSecret").Maybe().Return("", errors.New("test")) // We should be able to make an extension despite an empty enroll secret @@ -98,8 +97,8 @@ func TestNewExtensionDatabaseError(t *testing.T) { }() m := mocks.NewKnapsack(t) - m.On("ConfigStore").Return(agentbbolt.NewStore(log.NewNopLogger(), db, storage.ConfigStore.String())) - m.On("Slogger").Return(multislogger.New().Logger).Maybe() + m.On("ConfigStore").Return(agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ConfigStore.String())) + m.On("Slogger").Return(multislogger.NewNopLogger()).Maybe() e, err := NewExtension(context.TODO(), &mock.KolideService{}, m, ExtensionOpts{}) assert.NotNil(t, err) @@ -214,8 +213,8 @@ func TestExtensionEnroll(t *testing.T) { k := mocks.NewKnapsack(t) k.On("OsquerydPath").Maybe().Return("") k.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) + k.On("Slogger").Return(multislogger.NewNopLogger()) expectedEnrollSecret := "foo_secret" k.On("ReadEnrollSecret").Maybe().Return(expectedEnrollSecret, nil) @@ -353,8 +352,8 @@ func TestGenerateConfigs_CannotEnrollYet(t *testing.T) { k := mocks.NewKnapsack(t) k.On("OsquerydPath").Maybe().Return("") k.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) + k.On("Slogger").Return(multislogger.NewNopLogger()) k.On("ReadEnrollSecret").Maybe().Return("", errors.New("test")) e, err := NewExtension(context.TODO(), s, k, ExtensionOpts{}) @@ -526,12 +525,12 @@ func TestExtensionWriteBufferedLogsEmpty(t *testing.T) { defer cleanup() // Create the status logs bucket ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger).Maybe() + k.On("Slogger").Return(multislogger.NewNopLogger()).Maybe() k.On("ReadEnrollSecret").Maybe().Return("enroll_secret", nil) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{}) @@ -564,13 +563,13 @@ func TestExtensionWriteBufferedLogs(t *testing.T) { defer cleanup() // Create these buckets ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.ResultLogsStore.String()) - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ResultLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger).Maybe() + k.On("Slogger").Return(multislogger.NewNopLogger()).Maybe() k.On("ReadEnrollSecret").Maybe().Return("enroll_secret", nil) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{}) @@ -633,14 +632,14 @@ func TestExtensionWriteBufferedLogsEnrollmentInvalid(t *testing.T) { defer cleanup() // Create the status logs bucket ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) k.On("OsquerydPath").Maybe().Return("") k.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) k.On("ReadEnrollSecret").Maybe().Return("enroll_secret", nil) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{}) @@ -679,13 +678,13 @@ func TestExtensionWriteBufferedLogsLimit(t *testing.T) { defer cleanup() // Create the status logs bucket ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) - agentbbolt.NewStore(log.NewNopLogger(), db, storage.ResultLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ResultLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{ MaxBytesPerBatch: 100, @@ -752,13 +751,13 @@ func TestExtensionWriteBufferedLogsDropsBigLog(t *testing.T) { defer cleanup() // Create the status logs bucket ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) - agentbbolt.NewStore(log.NewNopLogger(), db, storage.ResultLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ResultLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{ MaxBytesPerBatch: 15, @@ -834,13 +833,13 @@ func TestExtensionWriteLogsLoop(t *testing.T) { defer cleanup() // Create the status logs bucket ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) - agentbbolt.NewStore(log.NewNopLogger(), db, storage.ResultLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ResultLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) mockClock := clock.NewMockClock() expectedLoggingInterval := 10 * time.Second @@ -964,13 +963,13 @@ func TestExtensionPurgeBufferedLogs(t *testing.T) { defer cleanup() // Create these buckets ahead of time - agentbbolt.NewStore(log.NewNopLogger(), db, storage.ResultLogsStore.String()) - agentbbolt.NewStore(log.NewNopLogger(), db, storage.StatusLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.ResultLogsStore.String()) + agentbbolt.NewStore(multislogger.NewNopLogger(), db, storage.StatusLogsStore.String()) k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("BboltDB").Return(db) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) max := 10 e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{MaxBufferedLogs: max}) @@ -1034,10 +1033,10 @@ func TestExtensionGetQueriesEnrollmentInvalid(t *testing.T) { } k := mocks.NewKnapsack(t) - k.On("ConfigStore").Return(storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String())) + k.On("ConfigStore").Return(storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String())) k.On("OsquerydPath").Maybe().Return("") k.On("LatestOsquerydPath", testifymock.Anything).Maybe().Return("") - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) k.On("ReadEnrollSecret").Return("enroll_secret", nil) e, err := NewExtension(context.TODO(), m, k, ExtensionOpts{}) @@ -1154,13 +1153,13 @@ func TestExtensionWriteResults(t *testing.T) { func TestLauncherRsaKeys(t *testing.T) { m := &mock.KolideService{} - configStore, err := storageci.NewStore(t, log.NewNopLogger(), storage.ConfigStore.String()) + configStore, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.ConfigStore.String()) require.NoError(t, err) require.NoError(t, err) k := mocks.NewKnapsack(t) k.On("ConfigStore").Return(configStore) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) _, err = NewExtension(context.TODO(), m, k, ExtensionOpts{}) require.NoError(t, err) @@ -1314,7 +1313,7 @@ func Test_setVerbose(t *testing.T) { t.Parallel() e := &Extension{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), } cfgBytes, err := json.Marshal(tt.initialConfig) @@ -1334,7 +1333,7 @@ func Test_setVerbose_EmptyConfig(t *testing.T) { t.Parallel() e := &Extension{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), } expectedCfg := map[string]any{ @@ -1355,7 +1354,7 @@ func Test_setVerbose_MalformedConfig(t *testing.T) { t.Parallel() e := &Extension{ - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), } malformedCfg := map[string]any{ diff --git a/pkg/osquery/runtime/history/history_test.go b/pkg/osquery/runtime/history/history_test.go index a3c39075d..5cda4757c 100644 --- a/pkg/osquery/runtime/history/history_test.go +++ b/pkg/osquery/runtime/history/history_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/launcher/ee/agent/storage" storageci "github.com/kolide/launcher/ee/agent/storage/ci" "github.com/kolide/launcher/ee/agent/types" + "github.com/kolide/launcher/pkg/log/multislogger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -220,7 +220,7 @@ func TestLatestInstanceUptimeMinutes(t *testing.T) { // nolint:paralleltest // setupStorage creates storage and seeds it with the given instances. func setupStorage(t *testing.T, seedInstances ...*Instance) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.OsqueryHistoryInstanceStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.OsqueryHistoryInstanceStore.String()) require.NoError(t, err) json, err := json.Marshal(seedInstances) diff --git a/pkg/osquery/runtime/runtime_test.go b/pkg/osquery/runtime/runtime_test.go index 24cac4db1..5d67ef8fb 100644 --- a/pkg/osquery/runtime/runtime_test.go +++ b/pkg/osquery/runtime/runtime_test.go @@ -18,7 +18,6 @@ import ( "time" "github.com/apache/thrift/lib/go/thrift" - "github.com/go-kit/kit/log" "github.com/kolide/kit/fsutil" "github.com/kolide/kit/testutil" "github.com/kolide/launcher/ee/agent/flags/keys" @@ -47,7 +46,7 @@ func TestMain(m *testing.M) { } defer rmBinDirectory() - s, err := storageci.NewStore(nil, log.NewNopLogger(), storage.OsqueryHistoryInstanceStore.String()) + s, err := storageci.NewStore(nil, multislogger.NewNopLogger(), storage.OsqueryHistoryInstanceStore.String()) if err != nil { fmt.Println("Failed to make new store") os.Exit(1) @@ -299,7 +298,7 @@ func TestBadBinaryPath(t *testing.T) { k := typesMocks.NewKnapsack(t) k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) runner := New( @@ -323,7 +322,7 @@ func TestWithOsqueryFlags(t *testing.T) { k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) runner := New( k, @@ -355,7 +354,7 @@ func TestFlagsChanged(t *testing.T) { k.On("WatchdogUtilizationLimitPercent").Return(20) k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) // Start the runner runner := New( @@ -447,7 +446,7 @@ func TestSimplePath(t *testing.T) { k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) runner := New( k, @@ -475,7 +474,7 @@ func TestMultipleShutdowns(t *testing.T) { k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) runner := New( k, @@ -530,7 +529,7 @@ func TestOsqueryDies(t *testing.T) { k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) runner := New( k, @@ -621,7 +620,7 @@ func TestExtensionSocketPath(t *testing.T) { k.On("OsqueryHealthcheckStartupDelay").Return(0 * time.Second).Maybe() k.On("WatchdogEnabled").Return(false) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) extensionSocketPath := filepath.Join(rootDirectory, "sock") runner := New( @@ -715,7 +714,7 @@ func setupOsqueryInstanceForTests(t *testing.T) (runner *Runner, teardown func() k.On("WatchdogUtilizationLimitPercent").Return(20) k.On("WatchdogDelaySec").Return(120) k.On("RegisterChangeObserver", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() - k.On("Slogger").Return(multislogger.New().Logger) + k.On("Slogger").Return(multislogger.NewNopLogger()) runner = New( k, diff --git a/pkg/traces/exporter/exporter_test.go b/pkg/traces/exporter/exporter_test.go index 65655f299..036d350f6 100644 --- a/pkg/traces/exporter/exporter_test.go +++ b/pkg/traces/exporter/exporter_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/go-kit/kit/log" "github.com/kolide/kit/version" "github.com/kolide/launcher/ee/agent/flags/keys" "github.com/kolide/launcher/ee/agent/storage" @@ -46,7 +45,7 @@ func TestNewTraceExporter(t *testing.T) { //nolint:paralleltest mockKnapsack.On("TraceSamplingRate").Return(1.0) mockKnapsack.On("TraceBatchTimeout").Return(1 * time.Minute) mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ExportTraces, keys.TraceSamplingRate, keys.TraceIngestServerURL, keys.DisableTraceIngestTLS, keys.TraceBatchTimeout).Return(nil) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) osqueryClient := mocks.NewQuerier(t) osqueryClient.On("Query", mock.Anything).Return([]map[string]string{ @@ -92,7 +91,7 @@ func TestNewTraceExporter_exportNotEnabled(t *testing.T) { mockKnapsack.On("TraceSamplingRate").Return(0.0) mockKnapsack.On("TraceBatchTimeout").Return(1 * time.Minute) mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ExportTraces, keys.TraceSamplingRate, keys.TraceIngestServerURL, keys.DisableTraceIngestTLS, keys.TraceBatchTimeout).Return(nil) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) traceExporter, err := NewTraceExporter(context.Background(), mockKnapsack, nil) require.NoError(t, err) @@ -129,7 +128,7 @@ func TestInterrupt_Multiple(t *testing.T) { //nolint:paralleltest mockKnapsack.On("TraceSamplingRate").Return(0.0) mockKnapsack.On("TraceBatchTimeout").Return(1 * time.Minute) mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ExportTraces, keys.TraceSamplingRate, keys.TraceIngestServerURL, keys.DisableTraceIngestTLS, keys.TraceBatchTimeout).Return(nil) - mockKnapsack.On("Slogger").Return(multislogger.New().Logger) + mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger()) traceExporter, err := NewTraceExporter(context.Background(), mockKnapsack, NewInitialTraceBuffer()) require.NoError(t, err) @@ -191,7 +190,7 @@ func Test_addDeviceIdentifyingAttributes(t *testing.T) { traceExporter := &TraceExporter{ knapsack: mockKnapsack, osqueryClient: mocks.NewQuerier(t), - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -245,7 +244,7 @@ func Test_addAttributesFromOsquery(t *testing.T) { traceExporter := &TraceExporter{ knapsack: typesmocks.NewKnapsack(t), osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -292,7 +291,7 @@ func TestPing(t *testing.T) { traceExporter := &TraceExporter{ knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: clientAuthenticator, @@ -382,7 +381,7 @@ func TestFlagsChanged_ExportTraces(t *testing.T) { //nolint:paralleltest knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -456,7 +455,7 @@ func TestFlagsChanged_TraceSamplingRate(t *testing.T) { //nolint:paralleltest knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -526,7 +525,7 @@ func TestFlagsChanged_TraceIngestServerURL(t *testing.T) { //nolint:paralleltest knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -601,7 +600,7 @@ func TestFlagsChanged_DisableTraceIngestTLS(t *testing.T) { //nolint:paralleltes knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: clientAuthenticator, @@ -676,7 +675,7 @@ func TestFlagsChanged_TraceBatchTimeout(t *testing.T) { //nolint:paralleltest knapsack: mockKnapsack, bufSpanProcessor: &bufspanprocessor.BufSpanProcessor{}, osqueryClient: osqueryClient, - slogger: multislogger.New().Logger, + slogger: multislogger.NewNopLogger(), attrs: make([]attribute.KeyValue, 0), attrLock: sync.RWMutex{}, ingestClientAuthenticator: newClientAuthenticator("test token", false), @@ -704,13 +703,13 @@ func TestFlagsChanged_TraceBatchTimeout(t *testing.T) { //nolint:paralleltest } func testServerProvidedDataStore(t *testing.T) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.ServerProvidedDataStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.ServerProvidedDataStore.String()) require.NoError(t, err) return s } func testTokenStore(t *testing.T) types.KVStore { - s, err := storageci.NewStore(t, log.NewNopLogger(), storage.TokenStore.String()) + s, err := storageci.NewStore(t, multislogger.NewNopLogger(), storage.TokenStore.String()) require.NoError(t, err) return s }