Skip to content

Manual fix: redirecting stderr to stdout to capture log output #279

@dbeatty10

Description

@dbeatty10

Details

Let's say you are capturing standard output in a Bash script like this to look for specific text within the logs:

OUTPUT=$(eval "dbt test --select test_get_enabled_snowplow_models --target $DATABASE --vars \"{'tag_var': 'random_tag'}\"" 2>&1)
EXIT_CODE=$?

if [[ $OUTPUT == *"Snowplow Warning: Untagged models referencing"* ]]; then
  UNTAGGED_MODEL_ERROR=true
fi

Fusion moves some logs from standard out to standard error, so you'd need to add something like 2>&1 to redirect stderr to wherever stdout is going:

OUTPUT=$(eval "dbt test --select test_get_enabled_snowplow_models --target $DATABASE --vars \"{'tag_var': 'random_tag'}\"" 2>&1)

Implementation

This is not the typical thing that we can autofix.

So I'd suggest we add this to manual_fixes since it lives outside the dbt project (but possibly still within the same git repo, like in CI tests)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions