Add --verbose
flag to dev and preview commands
#1928
Merged
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.
WHY are these changes introduced?
We are currently filtering out logs from the workerd runtime itself because they are largely non-actionable. We get app logs via WS, which is enough for most situations.
However, in some circumstances you might want to see the runtime logs, especially when you're doing something that crashes the runtime (http calls outside of request cycles, importing unsupported dependencies, etc.).
So far, this could be debugged using the
--legacy-runtime
. However, when moving to Vite we won't have access to the Node.js sandbox runtime anymore.WHAT is this pull request doing?
Introduce a
--verbose
flag that logs all the runtime information for debugging purposes.This flag is already used by
cli-kit
internally to output its own verbose logs. I'm not sure if we should use a different flag name to only output H2O logs instead, but I think mixing them with cli-kit is not bad either.A problem I found is that, when
cli-kit
detects--verbose
, it runsprocess.env.DEBUG='*'
... which is later picked up by Vite and it floods the terminal with all the verbose Vite logs. In order to prevent this, I'm replacing'*'
withh2:*,o2:*
so that Vite doesn't output its verbose logs.If, for whatever reason, the user wants Vite verbose logs, they can just run
DEBUG=* h2 dev
directly without our flag and it should all be printed (cli-kit, h2o and Vite).HOW to test your changes?
Try
h2 dev
,h2 dev --verbose
andDEBUG=* h2 dev
to see the differences intemplates/skeleton
andexamples/vite
.Note: I'm updating #1891 to also check the
o2:*
value inprocess.env.DEBUG
.