Skip to content
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

Add --verbose flag to dev and preview commands #1928

Merged
merged 2 commits into from
Apr 1, 2024
Merged

Conversation

frandiox
Copy link
Contributor

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 runs process.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 '*' with h2:*,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 and DEBUG=* h2 dev to see the differences in templates/skeleton and examples/vite.


Note: I'm updating #1891 to also check the o2:* value in process.env.DEBUG.

@frandiox frandiox requested a review from a team March 29, 2024 14:42
Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@frandiox frandiox merged commit 9351f9f into main Apr 1, 2024
13 checks passed
@frandiox frandiox deleted the fd-dev-verbose branch April 1, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants