mirror of https://github.com/databricks/cli.git
21 lines
509 B
Go
21 lines
509 B
Go
package progress
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type progressLogger int
|
|
|
|
var progressLoggerKey progressLogger
|
|
|
|
// NewContext returns a new Context that carries the specified progress logger.
|
|
func NewContext(ctx context.Context, logger *Logger) context.Context {
|
|
return context.WithValue(ctx, progressLoggerKey, logger)
|
|
}
|
|
|
|
// FromContext returns the progress logger value stored in ctx, if any.
|
|
func FromContext(ctx context.Context) (*Logger, bool) {
|
|
u, ok := ctx.Value(progressLoggerKey).(*Logger)
|
|
return u, ok
|
|
}
|