Skip to content

fix: route dev-server response logging through Vite's logger - #16858

Merged
Rich-Harris merged 1 commit into
sveltejs:version-3from
marwan562:fix/route-dev-logging-through-vite-logger
Aug 20, 2026
Merged

Rich-Harris merged 1 commit into
sveltejs:version-3from
marwan562:fix/route-dev-logging-through-vite-logger

Conversation

@marwan562

Copy link
Copy Markdown
Contributor

Fixes #16825

Summary

In the dev server, every SSR response is logged to the console (e.g. 200 GET /) via a raw console.log from log_response in the runtime server/internal.js. Because it bypasses Vite's logger, logLevel and customLogger have no effect on it.

This change routes dev-server response logging through Vite's resolved logger:

  • format_response(status, request) in packages/kit/src/runtime/server/internal.js is now a pure function that returns the formatted line instead of printing it, so the caller decides how to emit it.
  • The dev middleware (packages/kit/src/exports/vite/dev/index.js) emits the line via vite_dev_server.config.logger — logger.info for statuses < 400 and logger.error for >= 400. This means:
    • logLevel: "warn" (or "error"/"silent") now suppresses successful-request lines, while errors remain visible
    • a user-supplied customLogger receives the lines
  • Prerender logging (packages/kit/src/core/postbuild/prerender.js) is unchanged in behaviour — it still prints only >= 400 responses via console.log.
  • Renamed log_response -> format_response in the generated server module (core/sync/write_server.js) and the internal type declaration to match the new contract.

Testing

  • Added unit tests for format_response covering plain pages, data requests, route-resolution requests, remote-function requests, and error responses (all pass).
  • pnpm tsc-native and oxfmt --check pass on the changed files.

Changesets

patch for @sveltejs/kit.

@pkg-svelte-dev

ghost commented Aug 20, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 4fcce71:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/4fcce71590aacac9d3b4dd7bd9f503c90d405a02

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16858

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

ghost commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4fcce71

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you!

@Rich-Harris
Rich-Harris merged commit d0d3a33 into sveltejs:version-3 Aug 20, 2026
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.

Non-configurable request logs in console (SvelteKit 3)

2 participants