mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:52:26 -05:00
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
This commit is contained in:
parent
367bdca250
commit
083099a957
210 changed files with 506 additions and 662 deletions
|
|
@ -21,7 +21,6 @@ package media
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
|
|
@ -41,15 +40,13 @@ const BasePathWithID = BasePath + "/:" + IDKey
|
|||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// New returns a new auth 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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package media
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -82,7 +83,7 @@ import (
|
|||
// '422':
|
||||
// description: unprocessable
|
||||
func (m *Module) MediaCreatePOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "statusCreatePOSTHandler")
|
||||
l := logrus.WithField("func", "statusCreatePOSTHandler")
|
||||
authed, err := oauth.Authed(c, true, true, true, true) // posting new media is serious business so we want *everything*
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ type MediaCreateTestSuite struct {
|
|||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
storage *kv.KVStore
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
|
|
@ -79,7 +78,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
|
|||
// setup standard items
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.log = testrig.NewTestLog()
|
||||
testrig.InitTestLog()
|
||||
suite.storage = testrig.NewTestStorage()
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage)
|
||||
|
|
@ -88,7 +87,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
|
|||
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
|
||||
|
||||
// setup module being tested
|
||||
suite.mediaModule = mediamodule.New(suite.config, suite.processor, suite.log).(*mediamodule.Module)
|
||||
suite.mediaModule = mediamodule.New(suite.config, suite.processor).(*mediamodule.Module)
|
||||
}
|
||||
|
||||
func (suite *MediaCreateTestSuite) TearDownSuite() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package media
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -61,7 +62,7 @@ import (
|
|||
// '422':
|
||||
// description: unprocessable
|
||||
func (m *Module) MediaGETHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "MediaGETHandler")
|
||||
l := logrus.WithField("func", "MediaGETHandler")
|
||||
authed, err := oauth.Authed(c, true, true, true, true)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package media
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -91,7 +92,7 @@ import (
|
|||
// '422':
|
||||
// description: unprocessable
|
||||
func (m *Module) MediaPUTHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "MediaGETHandler")
|
||||
l := logrus.WithField("func", "MediaGETHandler")
|
||||
authed, err := oauth.Authed(c, true, true, true, true)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue