task icon indicating copy to clipboard operation
task copied to clipboard

Task label not reflected in logs when using output prefixed

Open nathanperkins opened this issue 1 year ago • 1 comments

  • Task version: v3.38.0 (h1:O7kgA6BfwktXHPrheByQO46p3teKtRuq1EpGnFxNzbo=)
  • Operating system: Linux
  • Experiments enabled: None

With task:

...

output: prefixed

tasks:
  build-image:
    label: build-image-{{.IMAGE_NAME}}
    requires:
      vars:
        - IMAGE_NAME
  ...

I expected the logging output to include the image name in the prefixed output, but it does not.

...
task: [build-image-foo] docker build \
...

...
[docker:build-image] #8 CACHED
[docker:build-image]
[docker:build-image] #9 exporting to image
[docker:build-image] #9 exporting layers done
...

nathanperkins avatar Aug 10 '24 06:08 nathanperkins

I guess this is a dupe of https://github.com/go-task/task/pull/893 and I need to use prefix instead. But the description of the label field is a bit misleading:

label - Overrides the name of the task in the output when a task is run. Supports variables.

When I read this, I thought for sure "in the output when a task is run" meant the logs.

It's not until you look way down the page that you see prefix, which is what you really want:

prefix - Defines a string to prefix the output of tasks running in parallel. Only used when the output mode is prefixed.

It's surprising that we need to specify the name twice to make the name consistent in the logs and the task summary. Maybe in v4 they could be merged?

At least, I'd suggest clarifying the description of label with something like:

Overrides the name of the task in the output summary when a task is started. Supports variables. Does not prefix log lines (see 'prefix' field instead).

If that description sounds good, I can make the change :)

nathanperkins avatar Aug 10 '24 06:08 nathanperkins