Skip to content

Commit

Permalink
Replace New().Logger with NewNopLogger() (#1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany authored Mar 4, 2024
1 parent 67a9019 commit bf03ab5
Show file tree
Hide file tree
Showing 34 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion cmd/launcher/desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func Test_desktopMonitorParentProcess(t *testing.T) { //nolint:paralleltest
runnerServer, err := runnerserver.New(multislogger.New().Logger, nil, nil)
runnerServer, err := runnerserver.New(multislogger.NewNopLogger(), nil, nil)
require.NoError(t, err)

// register client and get token
Expand Down
2 changes: 1 addition & 1 deletion cmd/launcher/signal_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestInterrupt_Multiple(t *testing.T) {

sigChannel := make(chan os.Signal, 1)
_, cancel := context.WithCancel(context.TODO())
sigListener := newSignalListener(sigChannel, cancel, multislogger.New().Logger)
sigListener := newSignalListener(sigChannel, cancel, multislogger.NewNopLogger())

// Let the signal listener run for a bit
go sigListener.Execute()
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/flags/flag_value_duration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestFlagValueDuration(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

d := NewDurationFlagValue(multislogger.New().Logger, keys.ControlRequestInterval, tt.options...)
d := NewDurationFlagValue(multislogger.NewNopLogger(), keys.ControlRequestInterval, tt.options...)
require.NotNil(t, d)

val := d.get(tt.controlServerValue)
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/flags/flag_value_float64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestFloat64FlagValue(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

d := NewFloat64FlagValue(multislogger.New().Logger, keys.ControlRequestInterval, tt.options...)
d := NewFloat64FlagValue(multislogger.NewNopLogger(), keys.ControlRequestInterval, tt.options...)
require.NotNil(t, d)

val := d.get(tt.controlServerValue)
Expand Down
2 changes: 1 addition & 1 deletion ee/agent/flags/flag_value_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestIntFlagValue(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

d := NewIntFlagValue(multislogger.New().Logger, keys.ControlRequestInterval, tt.options...)
d := NewIntFlagValue(multislogger.NewNopLogger(), keys.ControlRequestInterval, tt.options...)
require.NotNil(t, d)

val := d.get(tt.controlServerValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestUpdate_HappyPath(t *testing.T) {

testNc := &NotificationConsumer{
runner: mockNotifier,
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
}

// Send one notification
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestUpdate_HappyPath_NoAction(t *testing.T) {
mockNotifier := newNotifierMock()
testNc := &NotificationConsumer{
runner: mockNotifier,
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
}

// Send one notification that we haven't seen before
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestUpdate_ValidatesNotifications(t *testing.T) {
mockNotifier := newNotifierMock()
testNc := &NotificationConsumer{
runner: mockNotifier,
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
}

tests := []struct {
Expand Down
12 changes: 6 additions & 6 deletions ee/control/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestControlServiceRegisterConsumer(t *testing.T) {
mockKnapsack := typesMocks.NewKnapsack(t)
mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ControlRequestInterval)
mockKnapsack.On("ControlRequestInterval").Return(60 * time.Second)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

data := nopDataProvider{}
controlOpts := []Option{}
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestControlServiceRegisterConsumerMultiple(t *testing.T) {
mockKnapsack := typesMocks.NewKnapsack(t)
mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ControlRequestInterval)
mockKnapsack.On("ControlRequestInterval").Return(60 * time.Second)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

data := nopDataProvider{}
controlOpts := []Option{}
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestControlServiceUpdate(t *testing.T) {
mockKnapsack := typesMocks.NewKnapsack(t)
mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ControlRequestInterval)
mockKnapsack.On("ControlRequestInterval").Return(60 * time.Second)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

data := nopDataProvider{}
controlOpts := []Option{}
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestControlServiceFetch(t *testing.T) {
mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ControlRequestInterval)
mockKnapsack.On("ControlRequestInterval").Return(60 * time.Second)
mockKnapsack.On("ForceControlSubsystems").Return(false)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

data := &TestClient{tt.subsystems, tt.hashData}
controlOpts := []Option{}
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestControlServicePersistLastFetched(t *testing.T) {
mockKnapsack := typesMocks.NewKnapsack(t)
mockKnapsack.On("RegisterChangeObserver", mock.Anything, keys.ControlRequestInterval)
mockKnapsack.On("ControlRequestInterval").Return(60 * time.Second)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

if j >= tt.expectedUpdates {
// ForceControlSubsystems is only called when no update would normally be triggered
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestInterrupt_Multiple(t *testing.T) {
k := typesMocks.NewKnapsack(t)
k.On("ControlRequestInterval").Return(24 * time.Hour)
k.On("RegisterChangeObserver", mock.Anything, mock.Anything).Return()
k.On("Slogger").Return(multislogger.New().Logger)
k.On("Slogger").Return(multislogger.NewNopLogger())
data := &TestClient{}
control := New(k, data)

Expand Down
2 changes: 1 addition & 1 deletion ee/dataflatten/examples/flatten/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func main() {
}

opts := []dataflatten.FlattenOpts{
dataflatten.WithSlogger(multislogger.New().Logger),
dataflatten.WithSlogger(multislogger.NewNopLogger()),
dataflatten.WithNestedPlist(),
dataflatten.WithQuery(strings.Split(*flQuery, `/`)),
}
Expand Down
2 changes: 1 addition & 1 deletion ee/dataflatten/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func Flatten(data interface{}, opts ...FlattenOpts) ([]Row, error) {
fl := &Flattener{
rows: []Row{},
logLevel: levelFlattenDebug, // by default, log at a level below debug
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
queryWildcard: `*`,
queryKeyDenoter: `#`,
}
Expand Down
2 changes: 1 addition & 1 deletion ee/debug/checkups/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestInterrupt_Multiple(t *testing.T) {
mockKnapsack.On("LatestOsquerydPath").Return("").Maybe()
mockKnapsack.On("ServerProvidedDataStore").Return(nil).Maybe()
mockKnapsack.On("CurrentEnrollmentStatus").Return(types.Enrolled, nil).Maybe()
checkupLogger := NewCheckupLogger(multislogger.New().Logger, mockKnapsack)
checkupLogger := NewCheckupLogger(multislogger.NewNopLogger(), mockKnapsack)
mockKnapsack.AssertExpectations(t)

// Start and then interrupt
Expand Down
2 changes: 1 addition & 1 deletion ee/debug/checkups/tuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (tc *tufCheckup) selectedVersions() map[string]map[string]string {
"osqueryd": make(map[string]string),
}

nopLogger := multislogger.New().Logger
nopLogger := multislogger.NewNopLogger()

if launcherVersion, err := tuf.CheckOutLatestWithoutConfig("launcher", nopLogger); err != nil {
selectedVersions["launcher"]["path"] = fmt.Sprintf("error checking out latest version: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions ee/desktop/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestUpdate(t *testing.T) {
mockKnapsack.On("DesktopMenuRefreshInterval").Return(time.Millisecond * 250)
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

dir := t.TempDir()
r, err := New(mockKnapsack, nil, WithUsersFilesRoot(dir))
Expand Down Expand Up @@ -331,7 +331,7 @@ func TestSendNotification_NoProcessesYet(t *testing.T) {
mockKnapsack.On("DesktopMenuRefreshInterval").Return(time.Millisecond * 250)
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(multislogger.New().Logger)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())

dir := t.TempDir()
r, err := New(mockKnapsack, nil, WithUsersFilesRoot(dir))
Expand Down
2 changes: 1 addition & 1 deletion ee/desktop/runner/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestRootServer(t *testing.T) {

messenger := servermocks.NewMessenger(t)

monitorServer, err := New(multislogger.New().Logger, mockSack, messenger)
monitorServer, err := New(multislogger.NewNopLogger(), mockSack, messenger)
require.NoError(t, err)

go func() {
Expand Down
2 changes: 1 addition & 1 deletion ee/desktop/user/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestClient_GetAndShutdown(t *testing.T) {

socketPath := testSocketPath(t)
shutdownChan := make(chan struct{})
server, err := server.New(multislogger.New().Logger, validAuthToken, socketPath, shutdownChan, nil)
server, err := server.New(multislogger.NewNopLogger(), validAuthToken, socketPath, shutdownChan, nil)
require.NoError(t, err)

go func() {
Expand Down
4 changes: 2 additions & 2 deletions ee/tables/airport/table_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Test_generateAirportData_HappyPath(t *testing.T) {
constraints["query"] = []string{tt.query}
}

got, err := generateAirportData(tablehelpers.MockQueryContext(constraints), executor, multislogger.New().Logger)
got, err := generateAirportData(tablehelpers.MockQueryContext(constraints), executor, multislogger.NewNopLogger())
require.NoError(t, err)

executor.AssertExpectations(t)
Expand Down Expand Up @@ -218,7 +218,7 @@ func Test_generateAirportData_EdgeCases(t *testing.T) {

executor.On("Exec", mock.Anything).Return(tt.execReturn()).Once()

got, err := generateAirportData(tt.args.queryContext, executor, multislogger.New().Logger)
got, err := generateAirportData(tt.args.queryContext, executor, multislogger.NewNopLogger())
tt.assertion(t, err)
assert.Equal(t, tt.want, got)
})
Expand Down
4 changes: 2 additions & 2 deletions ee/tables/dataflattentable/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestDataFlattenTablePlist_Animals(t *testing.T) {
t.Parallel()

slogger := multislogger.New().Logger
slogger := multislogger.NewNopLogger()

// Test plist parsing both the json and xml forms
testTables := map[string]Table{
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestDataFlattenTablePlist_Animals(t *testing.T) {
func TestDataFlattenTables(t *testing.T) {
t.Parallel()

slogger := multislogger.New().Logger
slogger := multislogger.NewNopLogger()

var tests = []struct {
testTables map[string]Table
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/dev_table_tooling/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Test_generate(t *testing.T) {
},
}

table := Table{slogger: multislogger.New().Logger}
table := Table{slogger: multislogger.NewNopLogger()}

for _, tt := range tests {
tt := tt
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/firefox_preferences/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Test_generate(t *testing.T) {
},
}

table := Table{slogger: multislogger.New().Logger}
table := Table{slogger: multislogger.NewNopLogger()}

for _, tt := range tests {
tt := tt
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/firmwarepasswd/firmwarepasswd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestParser(t *testing.T) {

for _, tt := range tests {
tt := tt
parser := New(multislogger.New().Logger).parser
parser := New(multislogger.NewNopLogger()).parser

t.Run(tt.input, func(t *testing.T) {
t.Parallel()
Expand Down
8 changes: 4 additions & 4 deletions ee/tables/gsettings/gsettings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestGsettingsValues(t *testing.T) {
for _, tt := range tests {
tt := tt
table := GsettingsValues{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
getBytes: func(ctx context.Context, username string, buf *bytes.Buffer) error {
f, err := os.Open(filepath.Join("testdata", tt.filename))
require.NoError(t, err, "opening file %s", tt.filename)
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestPerUser(t *testing.T) {

for _, tt := range tests {
table := GsettingsValues{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
getBytes: execGsettings,
}
mockQC := tablehelpers.MockQueryContext(map[string][]string{
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestListKeys(t *testing.T) {
for _, tt := range tests {
tt := tt
table := GsettingsMetadata{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
cmdRunner: func(ctx context.Context, args []string, tmpdir string, buf *bytes.Buffer) error {
f, err := os.Open(filepath.Join("testdata", tt.filename))
require.NoError(t, err, "opening file %s", tt.filename)
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestGetType(t *testing.T) {
for _, tt := range tests {
tt := tt
table := GsettingsMetadata{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
cmdRunner: func(ctx context.Context, args []string, tmpdir string, buf *bytes.Buffer) error {
_, err := buf.WriteString(tt.input)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func Test_generateRecommendedUpdatesHappyPath(t *testing.T) {
t.Parallel()
table := Table{slogger: multislogger.New().Logger}
table := Table{slogger: multislogger.NewNopLogger()}

_, err := table.generate(context.Background(), tablehelpers.MockQueryContext(nil))

Expand Down
2 changes: 1 addition & 1 deletion ee/tables/mdmclient/mdmclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestTransformOutput(t *testing.T) {
},
}

table := Table{slogger: multislogger.New().Logger}
table := Table{slogger: multislogger.NewNopLogger()}

for _, tt := range tests {
tt := tt
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/pwpolicy/pwpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestQueries(t *testing.T) {
for _, tt := range tests {
tt := tt
testTable := &Table{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
execCC: execFaker(tt.file),
}

Expand Down
2 changes: 1 addition & 1 deletion ee/tables/tablehelpers/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestExec(t *testing.T) {
}

ctx := context.Background()
slogger := multislogger.New().Logger
slogger := multislogger.NewNopLogger()

for _, tt := range tests {
tt := tt
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/tablehelpers/getconstraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func WithAllowedValues(allowed []string) GetConstraintOpts {
func GetConstraints(queryContext table.QueryContext, columnName string, opts ...GetConstraintOpts) []string {

co := &constraintOptions{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
}

for _, opt := range opts {
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/windowsupdatetable/windowsupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestTable(t *testing.T) {
t.Parallel()

table := Table{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
queryFunc: tt.queryFunc,
}

Expand Down
2 changes: 1 addition & 1 deletion ee/tables/wmitable/wmitable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func TestQueries(t *testing.T) {
t.Parallel()

wmiTable := Table{slogger: multislogger.New().Logger}
wmiTable := Table{slogger: multislogger.NewNopLogger()}

var tests = []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/xfconf/xfconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_getUserConfig(t *testing.T) {
tmpDefaultDir, tmpUserDir := setUpConfigFiles(t)

xfconf := xfconfTable{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
}

testUsername := "testUser"
Expand Down
2 changes: 1 addition & 1 deletion ee/tables/xrdb/xrdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestXrdbParse(t *testing.T) {
for _, tt := range tests {
tt := tt
table := XRDBSettings{
slogger: multislogger.New().Logger,
slogger: multislogger.NewNopLogger(),
getBytes: func(ctx context.Context, display, username string, buf *bytes.Buffer) error {
f, err := os.Open(filepath.Join("testdata", tt.filename))
require.NoError(t, err, "opening file %s", tt.filename)
Expand Down
Loading

0 comments on commit bf03ab5

Please sign in to comment.