GODT-2059: Attempt to fix log crash

Don't store the logrus entry as it might be possible that the standard
logrus logger can get changed in between resulting in stale pointers
inside the `Logrus.Entry` instance.
This commit is contained in:
Leander Beernaert
2022-11-18 14:28:08 +01:00
committed by James Houlahan
parent eb2423b0ed
commit 2ff5731b39

View File

@ -21,13 +21,12 @@ import "github.com/sirupsen/logrus"
// IMAPLogger implements the writer interface for Gluon IMAP logs.
type IMAPLogger struct {
l *logrus.Entry
}
func NewIMAPLogger() *IMAPLogger {
return &IMAPLogger{l: logrus.WithField("pkg", "IMAP")}
return &IMAPLogger{}
}
func (l *IMAPLogger) Write(p []byte) (n int, err error) {
return l.l.WriterLevel(logrus.TraceLevel).Write(p)
return logrus.WithField("pkg", "IMAP").WriterLevel(logrus.TraceLevel).Write(p)
}