env.walk: inject contextual logging information
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
e09723861f
commit
f8a2109aba
@ -82,15 +82,9 @@ func NewEnv(ctx context.Context, s Solver, bootsrc, inputsrc string) (*Env, erro
|
|||||||
|
|
||||||
// Compute missing values in env configuration, and write them to state.
|
// Compute missing values in env configuration, and write them to state.
|
||||||
func (env *Env) Compute(ctx context.Context) error {
|
func (env *Env) Compute(ctx context.Context) error {
|
||||||
|
output, err := env.Walk(ctx, func(ctx context.Context, c *Component, out Fillable) error {
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
output, err := env.Walk(ctx, func(c *Component, out Fillable) error {
|
|
||||||
lg := lg.
|
|
||||||
With().
|
|
||||||
Str("path", c.Value().Path().String()).
|
|
||||||
Logger()
|
|
||||||
ctx := lg.WithContext(ctx)
|
|
||||||
|
|
||||||
lg.
|
lg.
|
||||||
Debug().
|
Debug().
|
||||||
Msg("[Env.Compute] processing")
|
Msg("[Env.Compute] processing")
|
||||||
@ -120,7 +114,7 @@ func (env *Env) Export(fs FS) (FS, error) {
|
|||||||
return fs, nil
|
return fs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type EnvWalkFunc func(*Component, Fillable) error
|
type EnvWalkFunc func(context.Context, *Component, Fillable) error
|
||||||
|
|
||||||
// Walk components and return any computed values
|
// Walk components and return any computed values
|
||||||
func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
||||||
@ -162,9 +156,7 @@ func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
|||||||
Str("state", t.State().String()).
|
Str("state", t.State().String()).
|
||||||
Logger()
|
Logger()
|
||||||
|
|
||||||
lg.
|
lg.Debug().Msg("cueflow task")
|
||||||
Debug().
|
|
||||||
Msg("cueflow task")
|
|
||||||
if t.State() != cueflow.Terminated {
|
if t.State() != cueflow.Terminated {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -189,6 +181,7 @@ func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
|||||||
With().
|
With().
|
||||||
Str("path", v.Path().String()).
|
Str("path", v.Path().String()).
|
||||||
Logger()
|
Logger()
|
||||||
|
ctx := lg.WithContext(ctx)
|
||||||
|
|
||||||
lg.Debug().Msg("Env.Walk: processing")
|
lg.Debug().Msg("Env.Walk: processing")
|
||||||
val := env.cc.Wrap(v, flowInst)
|
val := env.cc.Wrap(v, flowInst)
|
||||||
@ -204,7 +197,7 @@ func (env *Env) Walk(ctx context.Context, fn EnvWalkFunc) (*Value, error) {
|
|||||||
l.Lock()
|
l.Lock()
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
|
|
||||||
return fn(c, t)
|
return fn(ctx, c, t)
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
// Orchestrate execution with cueflow
|
// Orchestrate execution with cueflow
|
||||||
|
Reference in New Issue
Block a user