Fix Context Values are not logged.

Only the Sentry hook uses the values of the passed context. Therefore, we removed the values from our log statements when we shifted them from an extra `WithField` call to the context.
We fix this behavior by introducing a Logrus Hook that copies a fixed set of context values to the logging data.
This commit is contained in:
Maximilian Paß
2023-08-21 13:21:48 +02:00
parent a7d27e8f65
commit 306512bf9c
5 changed files with 50 additions and 6 deletions

View File

@ -40,6 +40,7 @@ func InitializeLogging(logLevel string, formatter dto.Formatter) {
TimestampFormat: TimestampFormat,
}
}
log.AddHook(&ContextHook{})
log.AddHook(&SentryHook{})
log.ExitFunc = func(i int) {
sentry.Flush(GracefulSentryShutdown)