1
0
mirror of https://github.com/go-task/task.git synced 2025-02-09 13:47:06 +02:00

Include task name in log output

This commit is contained in:
George Pollard 2020-11-06 09:27:42 +13:00 committed by Andrey Nering
parent d44207dd7f
commit fe917affd2
3 changed files with 5 additions and 3 deletions

View File

@ -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)).

View File

@ -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

View File

@ -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)
}