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

Improve logs in Vite dev server #1927

Merged
merged 5 commits into from Apr 1, 2024
Merged

Improve logs in Vite dev server #1927

merged 5 commits into from Apr 1, 2024

Conversation

frandiox
Copy link
Contributor

WHY are these changes introduced?

Logs in Vite dev server are quite chaotic at the moment.

WHAT is this pull request doing?

  • Filter out non-actionable Vite logs (most of them come from our Vite<>Workerd integration).
  • Adds spacing between Vite logs and Hydrogen logs.
  • Ensures most logs are output in order at the beginning.

HOW to test your changes?

It's easier to review this PR looking at each commit individually.
To test: run the development server in skeleton and Vite projects.

Before After
image image

@frandiox frandiox requested a review from a team March 29, 2024 13:34
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.

Looks great!

@@ -101,6 +103,7 @@ export function muteDevLogs({workerReload}: {workerReload?: boolean} = {}) {
injectLogReplacer('log');
injectLogReplacer('error');
injectLogReplacer('warn', warningDebouncer);
injectLogReplacer('debug', false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This just essentially makes all console.debug() messages not show up?

Copy link
Contributor Author

@frandiox frandiox Apr 1, 2024

Choose a reason for hiding this comment

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

It adds a hook to console.debug. Then, if it matches any of our replacers, it modifies the message or suppresses it. The false is just to avoid the debouncing logic.

[
// Log that gets entangled with our initial dev logs
([first]) =>
typeof first === 'string' &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we want to keep the logs clean, but does it ever concern you just how much we monkey console.log and family?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see this other PR: #1928

This makes me much more comfortable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, precisely :)

@frandiox frandiox merged commit 66e9e8b into main Apr 1, 2024
13 checks passed
@frandiox frandiox deleted the fd-improve-vite-logs branch April 1, 2024 10:28
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