diff --git a/pkg/runner/job_executor.go b/pkg/runner/job_executor.go index 3d86a8e..0c8cdb4 100644 --- a/pkg/runner/job_executor.go +++ b/pkg/runner/job_executor.go @@ -37,15 +37,18 @@ func newJobExecutor(info jobInfo) common.Executor { } stepExec := info.newStepExecutor(step) steps = append(steps, func(ctx context.Context) error { - err := stepExec(ctx) - if err != nil { - common.Logger(ctx).Errorf("%v", err) - common.SetJobError(ctx, err) - } else if ctx.Err() != nil { - common.Logger(ctx).Errorf("%v", ctx.Err()) - common.SetJobError(ctx, ctx.Err()) - } - return nil + stepName := step.String() + return (func(ctx context.Context) error { + err := stepExec(ctx) + if err != nil { + common.Logger(ctx).Errorf("%v", err) + common.SetJobError(ctx, err) + } else if ctx.Err() != nil { + common.Logger(ctx).Errorf("%v", ctx.Err()) + common.SetJobError(ctx, ctx.Err()) + } + return nil + })(withStepLogger(ctx, stepName)) }) } diff --git a/pkg/runner/logger.go b/pkg/runner/logger.go index 7949b4b..348f185 100644 --- a/pkg/runner/logger.go +++ b/pkg/runner/logger.go @@ -72,6 +72,11 @@ func WithJobLogger(ctx context.Context, jobName string, config *Config, masks *[ return common.WithLogger(ctx, rtn) } +func withStepLogger(ctx context.Context, stepName string) context.Context { + rtn := common.Logger(ctx).WithFields(logrus.Fields{"step": stepName}) + return common.WithLogger(ctx, rtn) +} + type entryProcessor func(entry *logrus.Entry) *logrus.Entry func valueMasker(insecureSecrets bool, secrets map[string]string, masks *[]string) entryProcessor {