// WrapContext 返回一个 context.Context 实例。如果 ctx == nil，需要确保 调用 logger.PutLogger()
347444
func WrapContext(ctx context.Context) context.Context {
	var objLogger *logger.Logger
	if ctx == nil {
		ctx = context.Background()
		objLogger = logger.GetLogger()
	} else {
		objLogger = GetLogger(ctx)
	}
	return context.WithValue(ctx, logKey, objLogger)
}
206568
func (s *StatusEvent) GetContext() string {
	if s == nil || s.Context == nil {
		return ""
	}
	return *s.Context
}
712335
func (ctx *CoalescingContext) AddContext(other context.Context) error {
	select {
	case ctx.mutateCh <- other:
		return nil
	case <-ctx.doneCh:
		return context.Canceled
	}
}
290180
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) {
	logger, ok = ctx.Value(ctxKeyLogger).(log.Logger)
	return
}
830161
func LoggerDummyContext() context.Context {
	ctx := context.Background()
	ctx = LoggerNewContext(ctx)
	return ctx
}
998267
func newContext(c *cli.Context) (ctx *Context, err error) {
	ctx = &Context{
		Context: c,
		netCtx:  context.Background(),
	}

	ctx.reporter, err = newReporter(ctx)
	if err != nil {
		return
	}

	ctx.logger, err = newLogger(ctx)
	if err != nil {
		return
	}

	ctx.stats, err = newStats(ctx)
	if err != nil {
		return
	}

	ctx.netCtx = ctx.embed(ctx.netCtx)

	return
}
78080
func Context(ctx context.Context) Option {
	return func(o *Options) {
		o.Context = ctx
	}
}
337113
func (c *Client) WithContext(ctx context.Context) *Client {
	newC := *c
	newC.ctx = ctx
	return &newC
}
959402
func (c *GroupRequestsVersionsRollupCall) Context(ctx context.Context) *GroupRequestsVersionsRollupCall {
	c.ctx_ = ctx
	return c
}
844075
func (p11w *Pkcs11Wrapper) InitContext() (err error) {

	// check if lib file exists
	if _, err = os.Stat(p11w.Library.Path); os.IsNotExist(err) {
		return
	}

	// try to initialize
	p11w.Context = pkcs11.New(p11w.Library.Path)
	err = p11w.Context.Initialize()
	if err != nil {
		return
	}

	// get library info
	p11w.Library.Info, err = p11w.Context.GetInfo()

	return

}
598963
func (l *Logger) GetContext(key string) (interface{}, bool) {
	l.globalsL.RLock()
	defer l.globalsL.RUnlock()
	val, ok := l.globals[key]
	return val, ok
}
594516
func (l *Logger) UpdateContext(update func(c Context) Context) {
	if l == disabledLogger {
		return
	}
	if cap(l.context) == 0 {
		l.context = make([]byte, 0, 500)
	}
	c := update(Context{*l})
	l.context = c.l.context
}
1142584
func (r *FlatChain) HandleContext(c *Context) {
	r.op(c, r.handleNext)
}
894193
func FromContext(ctx context.Context) (Logger, bool) {
	l, ok := ctx.Value(loggerKey).(Logger)
	return l, ok
}
441297
func NewContext(ctx context.Context, log Interface) context.Context {
	return context.WithValue(ctx, LogCTXKey, log)
}
156090
func (c *PutCall) Context(ctx context.Context) *PutCall {
	c.ctx_ = ctx
	return c
}
474517
func (c *PutBatchCall) Context(ctx context.Context) *PutBatchCall {
	c.ctx_ = ctx
	return c
}