mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-15 22:11:04 +00:00
[bug] Pass context in logging middleware (#1514)
This updates the middleware log.WithField calls that create new loggers to include the context the first time around. Without it the requestID does not get logged. Fixup from #1476
This commit is contained in:
parent
1ca5c62e25
commit
d39280ec33
1 changed files with 4 additions and 2 deletions
|
@ -57,7 +57,8 @@ func Logger() gin.HandlerFunc {
|
||||||
|
|
||||||
// Dump a stacktrace to error log
|
// Dump a stacktrace to error log
|
||||||
callers := errors.GetCallers(3, 10)
|
callers := errors.GetCallers(3, 10)
|
||||||
log.WithField("stacktrace", callers).Error(err)
|
log.WithContext(c.Request.Context()).
|
||||||
|
WithField("stacktrace", callers).Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
|
@ -75,7 +76,8 @@ func Logger() gin.HandlerFunc {
|
||||||
fields[5] = kv.Field{"path", path}
|
fields[5] = kv.Field{"path", path}
|
||||||
|
|
||||||
// Create log entry with fields
|
// Create log entry with fields
|
||||||
l := log.WithFields(fields...)
|
l := log.WithContext(c.Request.Context()).
|
||||||
|
WithFields(fields...)
|
||||||
|
|
||||||
// Default is info
|
// Default is info
|
||||||
lvl := level.INFO
|
lvl := level.INFO
|
||||||
|
|
Loading…
Reference in a new issue