mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
GODT-1954: Draft message support
Add special case handling for draft messages so that if a Draft is updated via an event it is correctly updated on the IMAP client via a the new `imap.MessageUpdated event`. This patch also updates Gluon to the latest version.
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@ -147,3 +148,26 @@ func MatchLogName(name string) bool {
|
||||
func MatchGUILogName(name string) bool {
|
||||
return regexp.MustCompile(`^gui_v.*\.log$`).MatchString(name)
|
||||
}
|
||||
|
||||
type logKey string
|
||||
|
||||
const logrusFields = logKey("logrus")
|
||||
|
||||
func WithLogrusField(ctx context.Context, key string, value interface{}) context.Context {
|
||||
fields, ok := ctx.Value(logrusFields).(logrus.Fields)
|
||||
if !ok || fields == nil {
|
||||
fields = logrus.Fields{}
|
||||
}
|
||||
|
||||
fields[key] = value
|
||||
return context.WithValue(ctx, logrusFields, fields)
|
||||
}
|
||||
|
||||
func LogFromContext(ctx context.Context) *logrus.Entry {
|
||||
fields, ok := ctx.Value(logrusFields).(logrus.Fields)
|
||||
if !ok || fields == nil {
|
||||
return logrus.WithField("ctx", "empty")
|
||||
}
|
||||
|
||||
return logrus.WithFields(fields)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user