package xlog import ( "context" "github.com/sirupsen/logrus" ) type entryKey struct { } func WithContext(ctx context.Context, entry *logrus.Entry) context.Context { return context.WithValue(ctx, entryKey{}, entry) } func FromContext(ctx context.Context) *logrus.Entry { if v, ok := ctx.Value(entryKey{}).(*logrus.Entry); ok { return v } return &logrus.Entry{} }