From fac5a0f3d2c499a246937f8847ff2a2be31ff85d Mon Sep 17 00:00:00 2001 From: Keepers Date: Wed, 5 Apr 2023 11:43:02 -0600 Subject: [PATCH] No warn logs (#3024) #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :broom: Tech Debt/Cleanup #### Test Plan - [x] :muscle: Manual --- src/.golangci.yml | 6 ++++-- .../connector/exchange/api/contacts.go | 5 ++--- src/internal/connector/exchange/api/events.go | 5 ++--- src/internal/connector/exchange/api/mail.go | 5 ++--- src/internal/connector/onedrive/drive_test.go | 18 +++++++++++------- src/internal/connector/onedrive/item.go | 2 +- src/internal/events/events_signal_windows.go | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/.golangci.yml b/src/.golangci.yml index 15f93b7b4..f0ce30498 100644 --- a/src/.golangci.yml +++ b/src/.golangci.yml @@ -29,7 +29,7 @@ linters-settings: forbid: # Don't allow creating contexts without logging in tests. Use an ignore # lower down to ensure usages of this outside of tests aren't reported. - - 'context\.(Background|TODO)(# tests should use tester\.NewContext )?' + - 'context\.(Background|TODO)(# tests should use tester\.NewContext)?' # Don't allow use of path as it hardcodes separator to `/`. # Use filepath instead. - '\bpath\.(Ext|Base|Dir|Join)' @@ -38,10 +38,12 @@ linters-settings: # Don't allow use of testify suite directly. Use one of the wrappers from # tester/suite.go instead. Use an ignore lower down to exclude packages # that result in import cycles if they try to use the wrapper. - - 'suite\.Suite(# tests should use one of the Suite wrappers in tester package )?' + - 'suite\.Suite(# tests should use one of the Suite wrappers in tester package)?' # All errors should be constructed and wrapped with the clues package. # String formatting should be avoided in favor of structured errors (ie: err.With(k, v)). - '(errors|fmt)\.(New|Stack|Wrap|Error)f?\((# error handling should use clues pkg)?' + # Avoid Warn-level logging in favor of Info or Error. + - 'Warn[wf]?\((# logging should use Info or Error)?' lll: line-length: 120 revive: diff --git a/src/internal/connector/exchange/api/contacts.go b/src/internal/connector/exchange/api/contacts.go index 90af25bac..f4f768519 100644 --- a/src/internal/connector/exchange/api/contacts.go +++ b/src/internal/connector/exchange/api/contacts.go @@ -258,11 +258,10 @@ func (c Contacts) GetAddedAndRemovedItemIDs( if len(os.Getenv("CORSO_URL_LOGGING")) > 0 { gri, err := builder.ToGetRequestInformation(ctx, options) if err != nil { - logger.Ctx(ctx).Errorw("getting builder info", "error", err) + logger.CtxErr(ctx, err).Error("getting builder info") } else { logger.Ctx(ctx). - With("user", user, "container", directoryID). - Warnw("builder path-parameters", "path_parameters", gri.PathParameters) + Infow("builder path-parameters", "path_parameters", gri.PathParameters) } } diff --git a/src/internal/connector/exchange/api/events.go b/src/internal/connector/exchange/api/events.go index 421e4a66b..dfa4d8541 100644 --- a/src/internal/connector/exchange/api/events.go +++ b/src/internal/connector/exchange/api/events.go @@ -292,11 +292,10 @@ func (c Events) GetAddedAndRemovedItemIDs( if len(os.Getenv("CORSO_URL_LOGGING")) > 0 { gri, err := builder.ToGetRequestInformation(ctx, nil) if err != nil { - logger.Ctx(ctx).Errorw("getting builder info", "error", err) + logger.CtxErr(ctx, err).Error("getting builder info") } else { logger.Ctx(ctx). - With("user", user, "container", calendarID). - Warnw("builder path-parameters", "path_parameters", gri.PathParameters) + Infow("builder path-parameters", "path_parameters", gri.PathParameters) } } diff --git a/src/internal/connector/exchange/api/mail.go b/src/internal/connector/exchange/api/mail.go index 095ab1525..03c302461 100644 --- a/src/internal/connector/exchange/api/mail.go +++ b/src/internal/connector/exchange/api/mail.go @@ -303,11 +303,10 @@ func (c Mail) GetAddedAndRemovedItemIDs( if len(os.Getenv("CORSO_URL_LOGGING")) > 0 { gri, err := builder.ToGetRequestInformation(ctx, options) if err != nil { - logger.Ctx(ctx).Errorw("getting builder info", "error", err) + logger.CtxErr(ctx, err).Error("getting builder info") } else { logger.Ctx(ctx). - With("user", user, "container", directoryID). - Warnw("builder path-parameters", "path_parameters", gri.PathParameters) + Infow("builder path-parameters", "path_parameters", gri.PathParameters) } } diff --git a/src/internal/connector/onedrive/drive_test.go b/src/internal/connector/onedrive/drive_test.go index 930569a94..26f8c5c85 100644 --- a/src/internal/connector/onedrive/drive_test.go +++ b/src/internal/connector/onedrive/drive_test.go @@ -299,11 +299,13 @@ func (suite *OneDriveSuite) TestCreateGetDeleteFolder() { ctx, flush := tester.NewContext() defer flush() - t := suite.T() - folderIDs := []string{} - folderName1 := "Corso_Folder_Test_" + common.FormatNow(common.SimpleTimeTesting) - folderElements := []string{folderName1} - gs := loadTestService(t) + var ( + t = suite.T() + folderIDs = []string{} + folderName1 = "Corso_Folder_Test_" + common.FormatNow(common.SimpleTimeTesting) + folderElements = []string{folderName1} + gs = loadTestService(t) + ) pager, err := PagerForSource(OneDriveSource, gs, suite.userID, nil) require.NoError(t, err, clues.ToCore(err)) @@ -317,11 +319,13 @@ func (suite *OneDriveSuite) TestCreateGetDeleteFolder() { defer func() { for _, id := range folderIDs { + ictx := clues.Add(ctx, "folder_id", id) + // deletes require unique http clients // https://github.com/alcionai/corso/issues/2707 - err := DeleteItem(ctx, loadTestService(t), driveID, id) + err := DeleteItem(ictx, loadTestService(t), driveID, id) if err != nil { - logger.Ctx(ctx).Warnw("deleting folder", "id", id, "error", err) + logger.CtxErr(ictx, err).Errorw("deleting folder") } } }() diff --git a/src/internal/connector/onedrive/item.go b/src/internal/connector/onedrive/item.go index 8eddfb6d6..6f9a2e0ab 100644 --- a/src/internal/connector/onedrive/item.go +++ b/src/internal/connector/onedrive/item.go @@ -280,7 +280,7 @@ func filterUserPermissions(ctx context.Context, perms []models.Permissionable) [ if gv2.GetDevice() != nil { logm.With("application_id", ptr.Val(gv2.GetDevice().GetId())) } - logm.Warn("untracked permission") + logm.Info("untracked permission") } // Technically GrantedToV2 can also contain devices, but the diff --git a/src/internal/events/events_signal_windows.go b/src/internal/events/events_signal_windows.go index 86ae519d8..d5119e476 100644 --- a/src/internal/events/events_signal_windows.go +++ b/src/internal/events/events_signal_windows.go @@ -7,5 +7,5 @@ import ( ) func signalDump(ctx context.Context) { - logger.Ctx(ctx).Warn("cannot send signal on Windows") + logger.Ctx(ctx).Error("cannot send signal on Windows") }