diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fdbfab2..5dbe2c0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Print task name before the command in the log output + ([#398](https://github.com/go-task/task/pull/398)). - Improve version reporting when building Task from source using Go Modules ([#462](https://github.com/go-task/task/pull/462)). diff --git a/task.go b/task.go index 77c901cd..4c268af1 100644 --- a/task.go +++ b/task.go @@ -366,7 +366,7 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi return nil case cmd.Cmd != "": if e.Verbose || (!cmd.Silent && !t.Silent && !e.Taskfile.Silent && !e.Silent) { - e.Logger.Errf(logger.Green, "task: %s", cmd.Cmd) + e.Logger.Errf(logger.Green, "task: [%s] %s", t.Name(), cmd.Cmd) } if e.Dry { @@ -397,7 +397,7 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi Stderr: stdErr, }) if execext.IsExitError(err) && cmd.IgnoreError { - e.Logger.VerboseErrf(logger.Yellow, "task: command error ignored: %v", err) + e.Logger.VerboseErrf(logger.Yellow, "task: [%s] command error ignored: %v", t.Name(), err) return nil } return err diff --git a/task_test.go b/task_test.go index 4c16d49c..6eed315e 100644 --- a/task_test.go +++ b/task_test.go @@ -626,7 +626,7 @@ func TestDry(t *testing.T) { assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "build"})) - assert.Equal(t, "task: touch file.txt", strings.TrimSpace(buff.String())) + assert.Equal(t, "task: [build] touch file.txt", strings.TrimSpace(buff.String())) if _, err := os.Stat(file); err == nil { t.Errorf("File should not exist %s", file) }