mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 22:36:14 -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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"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
|
// create the actual engine here -- this is the core request routing handler for gts
|
||||||
engine := gin.Default()
|
engine := gin.New()
|
||||||
engine.MaxMultipartMemory = 8 << 20 // 8 MiB
|
|
||||||
|
// 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.
|
// set up IP forwarding via x-forward-* headers.
|
||||||
if err := engine.SetTrustedProxies(cfg.TrustedProxies); err != nil {
|
if err := engine.SetTrustedProxies(cfg.TrustedProxies); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,17 @@
|
||||||
|
|
||||||
package testrig
|
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
|
// NewTestLog returns a trace level logger for testing
|
||||||
func NewTestLog() *logrus.Logger {
|
func NewTestLog() *logrus.Logger {
|
||||||
log := logrus.New()
|
logger, err := log.New("trace")
|
||||||
log.SetLevel(logrus.TraceLevel)
|
if err != nil {
|
||||||
return log
|
panic(err)
|
||||||
|
}
|
||||||
|
return logger
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue