You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
373 B
19 lines
373 B
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{} |
|
}
|
|
|