-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print logs to stderr #4922
Closed
Closed
Print logs to stderr #4922
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@shopify/ui-extensions-dev-console-app': patch | ||
'@shopify/cli-kit': patch | ||
'@shopify/theme': patch | ||
'@shopify/app': patch | ||
--- | ||
|
||
Print all log messages to stderr instead of stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I suggest a
export function output(content: outputMessage, logger: Logger = consoleLog): void {
?
That way all the
output{log,warn,error}
would all go to stderr and we'd make it explicit which one goes to stdout?STDOUT = scriptable output
STDERR = logging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
goes to stdout...I think the idea is that we have several output functions based on log level, but by default all log to
consoleWarn
which usesconsole.warn
which goes to stderr.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I'm saying. Let's change this so that console.log is only used intentionally.
outputInfo
- STDERR loglevel infooutputDebug
- STDERR loglevel debugoutputWarn
- STDERR loglevel warnoutputError
- STDERR loglevel erroroutput
- STDOUT. Use only for JSON or whatever could be piped into another bash script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should ever log anything without specifying a log level. We can default everything to stderr and make stdout an explicit choice by specifying stdout as the logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk I think output is output and logging is logging. I personally don't see a problem with these two things:
STDOUT is for piping & scripts. Why would we want a loglevel in there? What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because, while we don't currently support it, many programs have a
silent
log level which doesn't print anything. And I think we should ultimately support that. Keeping everything with log levels gives us more room to fine-tune logging behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a good example: https://docs.npmjs.com/cli/v10/using-npm/config#loglevel
Silent is just another log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that mean that
--json --silent
do nothing at all? There's always&> /dev/null
?Whenever I'm scripting, I'm mostly annoyed by shit showing up in STDOUT and that's why I'd want
--silent
, but if it doesn't, then I don't see the point.One of
pnpm
ornx
is an example offender here. If I want to run theshopify theme language-server
with the dev build in Shopify/cli, I can only do that by running the build node package stuff because otherwise pnpm & nx are outputting crap to STDOUT that don't fit the LSP.Same goes for
pnpm shopify theme check --json
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that reason, whenever I want to test a Shopify/theme-tools bump in vim. I have to use a script in my $HOME/bin that is this:
Which means I need
pnpm run build
any time I want to test it too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried
pnpm --silent shopify:run ...
--silent
quiets pnpmshopify:run
skips the build step (you have to runpnpm shopify build
first, but anyway you need to do that in your script)