diff options
author | 2021-10-11 05:37:33 -0700 | |
---|---|---|
committer | 2021-10-11 14:37:33 +0200 | |
commit | 083099a9575f8b2fac22c1d4a51a9dd0e2201243 (patch) | |
tree | d1787aa544679c433f797d2313ce532250fe574f /internal/api/client/account | |
parent | Handle forwarded messages (#273) (diff) | |
download | gotosocial-083099a9575f8b2fac22c1d4a51a9dd0e2201243.tar.xz |
reference global logrus (#274)
* reference logrus' global logger instead of passing and storing a logger reference everywhere
* always directly use global logrus logger instead of referencing an instance
* test suites should also directly use the global logrus logger
* rename gin logging function to clarify that it's middleware
* correct comments which erroneously referenced removed logger parameter
* setting log level for tests now uses logrus' exported type instead of the string value, to guarantee error isn't possible
Diffstat (limited to 'internal/api/client/account')
-rw-r--r-- | internal/api/client/account/account.go | 5 | ||||
-rw-r--r-- | internal/api/client/account/account_test.go | 6 | ||||
-rw-r--r-- | internal/api/client/account/accountcreate.go | 3 | ||||
-rw-r--r-- | internal/api/client/account/accountupdate.go | 3 | ||||
-rw-r--r-- | internal/api/client/account/accountverify.go | 3 | ||||
-rw-r--r-- | internal/api/client/account/relationships.go | 3 | ||||
-rw-r--r-- | internal/api/client/account/statuses.go | 3 | ||||
-rw-r--r-- | internal/api/client/account/unfollow.go | 3 |
8 files changed, 15 insertions, 14 deletions
diff --git a/internal/api/client/account/account.go b/internal/api/client/account/account.go index 42aca3283..bb11888d3 100644 --- a/internal/api/client/account/account.go +++ b/internal/api/client/account/account.go @@ -23,7 +23,6 @@ import ( "strings" "github.com/gin-gonic/gin" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/processing" @@ -75,15 +74,13 @@ const ( type Module struct { config *config.Config processor processing.Processor - log *logrus.Logger } // New returns a new account module -func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { +func New(config *config.Config, processor processing.Processor) api.ClientModule { return &Module{ config: config, processor: processor, - log: log, } } diff --git a/internal/api/client/account/account_test.go b/internal/api/client/account/account_test.go index 0acc611df..f33fd735f 100644 --- a/internal/api/client/account/account_test.go +++ b/internal/api/client/account/account_test.go @@ -8,7 +8,6 @@ import ( "git.iim.gay/grufwub/go-store/kv" "github.com/gin-gonic/gin" - "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/api/client/account" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -26,7 +25,6 @@ type AccountStandardTestSuite struct { suite.Suite config *config.Config db db.DB - log *logrus.Logger tc typeutils.TypeConverter storage *kv.KVStore federator federation.Federator @@ -59,10 +57,10 @@ func (suite *AccountStandardTestSuite) SetupTest() { suite.config = testrig.NewTestConfig() suite.db = testrig.NewTestDB() suite.storage = testrig.NewTestStorage() - suite.log = testrig.NewTestLog() + testrig.InitTestLog() suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) - suite.accountModule = account.New(suite.config, suite.processor, suite.log).(*account.Module) + suite.accountModule = account.New(suite.config, suite.processor).(*account.Module) testrig.StandardDBSetup(suite.db, nil) testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") } diff --git a/internal/api/client/account/accountcreate.go b/internal/api/client/account/accountcreate.go index 3fab1488f..6497d4d01 100644 --- a/internal/api/client/account/accountcreate.go +++ b/internal/api/client/account/accountcreate.go @@ -20,6 +20,7 @@ package account import ( "errors" + "github.com/sirupsen/logrus" "net" "net/http" @@ -67,7 +68,7 @@ import ( // '500': // description: internal error func (m *Module) AccountCreatePOSTHandler(c *gin.Context) { - l := m.log.WithField("func", "accountCreatePOSTHandler") + l := logrus.WithField("func", "accountCreatePOSTHandler") authed, err := oauth.Authed(c, true, true, false, false) if err != nil { l.Debugf("couldn't auth: %s", err) diff --git a/internal/api/client/account/accountupdate.go b/internal/api/client/account/accountupdate.go index 35eaaad6f..8534f5805 100644 --- a/internal/api/client/account/accountupdate.go +++ b/internal/api/client/account/accountupdate.go @@ -20,6 +20,7 @@ package account import ( "fmt" + "github.com/sirupsen/logrus" "net/http" "strconv" @@ -100,7 +101,7 @@ import ( // '400': // description: bad request func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) { - l := m.log.WithField("func", "accountUpdateCredentialsPATCHHandler") + l := logrus.WithField("func", "accountUpdateCredentialsPATCHHandler") authed, err := oauth.Authed(c, true, true, true, true) if err != nil { l.Debugf("couldn't auth: %s", err) diff --git a/internal/api/client/account/accountverify.go b/internal/api/client/account/accountverify.go index c5c40a03d..6b8d1f92c 100644 --- a/internal/api/client/account/accountverify.go +++ b/internal/api/client/account/accountverify.go @@ -19,6 +19,7 @@ package account import ( + "github.com/sirupsen/logrus" "net/http" "github.com/gin-gonic/gin" @@ -51,7 +52,7 @@ import ( // '404': // description: not found func (m *Module) AccountVerifyGETHandler(c *gin.Context) { - l := m.log.WithField("func", "accountVerifyGETHandler") + l := logrus.WithField("func", "accountVerifyGETHandler") authed, err := oauth.Authed(c, true, false, false, true) if err != nil { l.Debugf("couldn't auth: %s", err) diff --git a/internal/api/client/account/relationships.go b/internal/api/client/account/relationships.go index d350209af..bb942d18a 100644 --- a/internal/api/client/account/relationships.go +++ b/internal/api/client/account/relationships.go @@ -1,6 +1,7 @@ package account import ( + "github.com/sirupsen/logrus" "net/http" "github.com/gin-gonic/gin" @@ -47,7 +48,7 @@ import ( // '404': // description: not found func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) { - l := m.log.WithField("func", "AccountRelationshipsGETHandler") + l := logrus.WithField("func", "AccountRelationshipsGETHandler") authed, err := oauth.Authed(c, true, true, true, true) if err != nil { diff --git a/internal/api/client/account/statuses.go b/internal/api/client/account/statuses.go index 4841d86df..ab1d4e2e6 100644 --- a/internal/api/client/account/statuses.go +++ b/internal/api/client/account/statuses.go @@ -19,6 +19,7 @@ package account import ( + "github.com/sirupsen/logrus" "net/http" "strconv" @@ -96,7 +97,7 @@ import ( // '404': // description: not found func (m *Module) AccountStatusesGETHandler(c *gin.Context) { - l := m.log.WithField("func", "AccountStatusesGETHandler") + l := logrus.WithField("func", "AccountStatusesGETHandler") authed, err := oauth.Authed(c, false, false, false, false) if err != nil { diff --git a/internal/api/client/account/unfollow.go b/internal/api/client/account/unfollow.go index 7ac9697d5..b18903c8a 100644 --- a/internal/api/client/account/unfollow.go +++ b/internal/api/client/account/unfollow.go @@ -19,6 +19,7 @@ package account import ( + "github.com/sirupsen/logrus" "net/http" "github.com/gin-gonic/gin" @@ -60,7 +61,7 @@ import ( // '404': // description: not found func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) { - l := m.log.WithField("func", "AccountUnfollowPOSTHandler") + l := logrus.WithField("func", "AccountUnfollowPOSTHandler") authed, err := oauth.Authed(c, true, true, true, true) if err != nil { l.Debug(err) |