Skip to content

--output-format json to stdout should not print info logs in json tostderr when output stream redirected #2476

@jpadams

Description

@jpadams

Currently if you redirect stdout via > outfiile or | jq or similar, you get all of the info(?) logs in json format from stderr dumped to the screen. Perhaps this is by design, but I was surprised by that given that I only wanted the output to pipe cleanly to jq. To declutter my screen I used standard redirect of stderr to /dev/null: 2>/dev/null.

Example:
From https://docs.dagger.io/1226/handling-outputs#piping-a-result or https://docs.dagger.io/1228/handling-outputs#piping-a-result (slug update in progress):

This behavior might be called out here in the doc itself:
image

start local registry on 5042:

docker run -d -p 5042:5000 --restart=always --name localregistry registry:2 
package main

import (
    "dagger.io/dagger"
    "universe.dagger.io/docker"
)

dagger.#Plan & {
    actions: {
        pull: docker.#Pull & {
            source: "alpine"
        }
        push: docker.#Push & {
            image: pull.output
            dest:  "localhost:5042/alpine"
        }
    }
}

looks great with --output-format json:
dagger do push
image

looks great without redirect:
dagger --output-format json do push
image

redirects bring out the logs:
dagger --output-format json do push > /tmp/sldjflsdj
image

dagger --output-format json do push | jq '.result'
image

related to #2474

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions