mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 15:56:16 -06:00
start messing around with logger
This commit is contained in:
parent
d39d93e852
commit
2905a13d16
3 changed files with 32 additions and 6 deletions
1
internal/router/logger.go
Normal file
1
internal/router/logger.go
Normal file
|
|
@ -0,0 +1 @@
|
|||
package router
|
||||
|
|
@ -21,6 +21,7 @@ package router
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -119,8 +120,26 @@ func New(ctx context.Context, cfg *config.Config, db db.DB, logger *logrus.Logge
|
|||
}
|
||||
|
||||
// create the actual engine here -- this is the core request routing handler for gts
|
||||
engine := gin.Default()
|
||||
engine.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||
engine := gin.New()
|
||||
|
||||
// paths to not log requests to
|
||||
dontLog := []string{
|
||||
// don't print requests to the streaming API to avoid leaking tokens
|
||||
"/api/v1/streaming",
|
||||
}
|
||||
|
||||
// instruct gin to write out to our logger
|
||||
loggingConfig := gin.LoggerConfig{
|
||||
Formatter: logFormatter,
|
||||
Output: log.Writer(),
|
||||
SkipPaths: dontLog,
|
||||
}
|
||||
|
||||
engine.Use(gin.RecoveryWithWriter(logger.Writer()))
|
||||
engine.Use(gin.LoggerWithConfig(loggingConfig))
|
||||
|
||||
// 8 MiB
|
||||
engine.MaxMultipartMemory = 8 << 20
|
||||
|
||||
// set up IP forwarding via x-forward-* headers.
|
||||
if err := engine.SetTrustedProxies(cfg.TrustedProxies); err != nil {
|
||||
|
|
|
|||
|
|
@ -18,11 +18,17 @@
|
|||
|
||||
package testrig
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// NewTestLog returns a trace level logger for testing
|
||||
func NewTestLog() *logrus.Logger {
|
||||
log := logrus.New()
|
||||
log.SetLevel(logrus.TraceLevel)
|
||||
return log
|
||||
logger, err := log.New("trace")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return logger
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue