[Bug]: Logging should be done to STDERR by default. STDOUT should be reserved for scriptable output.
Please confirm that you have:
- [X] Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
- [X] Reproduced the issue in the latest CLI version.
In which of these areas are you experiencing a problem?
Other
Expected behavior
I noticed that logging is done by default to STDOUT (even debug logging, for theme check anyway). Shouldn’t that be sent to STDERR by default?
Logging to STDOUT when it isn’t meant to be captured by a script makes the CLI non-composable/non-scriptable.
For instance, shopify theme check --verbose --output json will have non-JSON output in STDOUT and makes | jq break.
IMO STDOUT should be intentional, not the default.
Actual behavior
IMO all of these should use STDERR by default. STDOUT is the wrong default.
- outputDebug should log to STDERR by default (console.error)
- outputInfo
- outputWarn
Verbose output
$ shopify theme check --output json --verbose | jq .
jq: parse error: Invalid numeric literal at line 1, column 14
Reproduction steps
-
shopify theme check --output json --verbose | jq .-- get malformed JSON because debug logging isn't JSON.
Operating System
All
Shopify CLI version (check your project's package.json if you're not sure)
3.60
+1
This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.
P.S. You can learn more about why we stale issues here.
If we did this, we wouldn't have had https://github.com/Shopify/lighthouse-ci-action/issues/87
I've created a draft PR with a potential solution for this: https://github.com/Shopify/cli/pull/4922, in case someone wants to continue
I would even suggest having a new output helper named output that would be the only one that logs to STDOUT.
That way you can pick from the list:
-
outputInfo- STDERR loglevel info -
outputDebug- STDERR loglevel debug -
outputWarn- STDERR loglevel warn -
outputError- STDERR loglevel error -
output- STDOUT. Use only for JSON or whatever could be piped into another bash script.
This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.
P.S. You can learn more about why we stale issues here.
Still relevant
This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.
P.S. You can learn more about why we stale issues here.
still relevant I believe