feat: use logger instead of console where possible - #17818
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 77b476d The changes in this PR will be included in the next version bump. This PR includes changesets to release 425 packages
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 |
`virtual:astro:manifest` statically imports `virtual:astro:pages`, and the runtime logger made `astro:content` reach the ambient manifest transitively (astro:content -> assets/runtime -> runtime/server -> astro-global -> getGlobalLogger -> manifest/ambient). Loading the content config during sync runs in the `astro` environment, where the pages plugin did not apply, so the manifest failed to resolve its page map and content type generation crashed. The serialized-manifest and routes plugins already cover `astro`; this brings the pages plugin in line with them. Page modules are imported lazily from the generated map, so evaluating it in the runnable dev environment is cheap. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
Unit tests for `getGlobalLogger()` (manifest logger vs. console fallback, level handling, destination swaps, identity) and `astroToRuntimeLogger()`. Integration coverage through a new `runtime-logger` fixture whose middleware entrypoint calls `getEntry()` at module scope, outside any request: with no request state to carry a logger, the warning only reaches the user-configured destination if `getGlobalLogger()` resolves the ambient manifest's logger. The fixture also exercises the render-time `set:html`-through-spread and hydration-directive-on-an-Astro-component warnings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
Merging this PR will degrade performance by 15.71%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | Build: hybrid site (static + server) |
1.4 s | 1.7 s | -15.71% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/runtime-logger (77b476d) with main (f8e9458)1
Footnotes
`getGlobalLogger()` reaches the ambient manifest, and `virtual:astro:manifest` statically imports `virtual:astro:renderers` and `virtual:astro:pages`. Calling it from `astro/runtime/server` — which every compiled page imports — therefore connected every page's module graph to every renderer and every other page, and Astro's CSS crawling started injecting unrelated styles. `@astrojs/vue`'s app-entrypoint CSS test caught it: a page with no Vue component was served the appEntrypoint's global stylesheet. Revert `astro-global`, `render/util` and `render/astro/instance` to `console`, and drop the integration coverage for those three warnings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
Replaces `getGlobalLogger()`, which reached the logger through the ambient manifest. `virtual:astro:manifest` statically imports `virtual:astro:renderers` and `virtual:astro:pages`, so any module a page imports that reaches the manifest drags every renderer and every page into that page's module graph — and Astro's CSS crawling then injects unrelated styles. `@astrojs/vue`'s app-entrypoint CSS test caught the first version of this through `astro/runtime/server`; `astro:content` had the same defect for any project combining content collections with a renderer that has an `appEntrypoint`. `virtual:astro:logger` is a leaf — it imports only the user's configured destination — so `astro:content` builds its logger from that instead, and the content runtime factories take it as a parameter. The destination is the same instance the manifest's `logger()` thunk resolves, so content logs still reach the user's destination; only the AstroLogger wrapper differs. The logger virtual module is now always registered (exporting `null` plus the resolved level when unconfigured) so the static `astro:content` template can import it unconditionally, and `getGlobalLogger()` is gone. Also reverts the pages-plugin `astro` environment fix: it only existed because `astro:content` pulled the manifest into content sync, which it no longer does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
Minor bumps for the two public signature changes — the `logger` parameter on `LocalImageService.transform()` and on the cache provider `onRequest()` context — plus patches for the console-to-logger routing in astro and the Vercel dev image service that has to forward the new argument. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
The loader schema warning moved from `console.warn` to `logger.warn`, so the test's console patch no longer saw it. Capture the messages with an `AstroLogger` destination passed via `_logger` instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
`stripInternal` keeps `_logger` out of the emitted declarations, so the sync tests need to suppress the type error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUdtfZXucgDyU666b6aCRG
florian-lefebvre
marked this pull request as ready for review
August 26, 2026 08:23
Princesseuh
reviewed
Aug 27, 2026
matthewp
approved these changes
Aug 27, 2026
Extends the `logger` argument beyond `transform()`: `getURL`, `getSrcSet`, `getHTMLAttributes`, `validateOptions`, `getRemoteSize`, and `parseURL` now receive Astro's runtime logger too, so a custom service can log from any hook through the configured destination instead of the console. The hooks reached from `getImage()` had no logger to forward, so the generated `astro:assets` and `virtual:astro:get-image` modules build one from `virtual:astro:logger` and pass it in — the same approach `astro:content` uses. That module is a leaf, so reaching the user's destination through it cannot drag every renderer and page into an importer's module graph the way the manifest would. The client branch gets a console shim instead: there is no configured destination in the browser, and pulling the logger implementation in just for `inferRemoteSize()` would be dead weight. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
@Princesseuh done in 5e48ac5 |
Princesseuh
approved these changes
Aug 28, 2026
ematipico
approved these changes
Sep 1, 2026
Merged
1 task
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Sep 9, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.10` → `7.3.1`](https://renovatebot.com/diffs/npm/astro/7.2.10/7.3.1) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v7.3.1`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#731) [Compare Source](https://github.com/withastro/astro/compare/astro@7.3.0...astro@7.3.1) ##### Patch Changes - [#​17899](withastro/astro#17899) [`0389640`](withastro/astro@0389640) Thanks [@​ematipico](https://github.com/ematipico)! - Fixes an error that prevented projects using `astro:assets` from starting or building ### [`v7.3.0`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#730) [Compare Source](https://github.com/withastro/astro/compare/astro@7.2.10...astro@7.3.0) ##### Minor Changes - [#​17767](withastro/astro#17767) [`ce7c91f`](withastro/astro@ce7c91f) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Adds `--ignore-lock` flag to `astro preview`, allowing multiple preview servers to run simultaneously on different ports. This is useful for E2E testing workflows (e.g., Playwright) that need to run several preview servers at once. - [#​17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a `logger` parameter to image services hooks Custom image services now receive Astro's runtime logger as an extra argument. Messages logged with it are routed through the destination configured in `logger` and respect your log level, instead of being written straight to the console: ```ts import type { LocalImageService } from 'astro'; const service: LocalImageService = { // ... async transform(inputBuffer, transform, imageConfig, logger) { logger.warn(`Could not optimize "${transform.src}". Passing it through unchanged.`); return { data: inputBuffer, format: 'png' }; }, }; ``` Astro's built-in Sharp service now uses this logger for the warnings it emits when it encounters an unexpected or unsupported source format. - [#​17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Adds `logger` to the context object passed to cache providers Custom cache providers now receive Astro's runtime logger on the context passed to `onRequest()`. Messages logged with it are routed through the destination configured in `logger` and respect your log level, instead of being written straight to the console: ```ts import type { CacheProvider } from 'astro'; const provider: CacheProvider = { name: 'my-cache', async onRequest({ request, url, logger }, next) { logger.warn(`Skipping cache for ${url.pathname} because the response sets a cookie.`); return next(); }, // ... }; ``` Astro's built-in `memoryCache()` provider now uses this logger for the warnings it emits when it skips caching a response that sets cookies, and when a background revalidation fails. ##### Patch Changes - [#​17818](withastro/astro#17818) [`c0b6581`](withastro/astro@c0b6581) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Updates Astro's remaining internal warnings and errors to be written through the configured logger instead of directly to the console, when possible - [#​17886](withastro/astro#17886) [`e747cba`](withastro/astro@e747cba) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes the memory cache provider to skip responses with `Vary: Cookie` or `Vary: *` - [#​17885](withastro/astro#17885) [`916b738`](withastro/astro@916b738) Thanks [@​Princesseuh](https://github.com/Princesseuh)! - Improves build performance for sites with a large number of pages coming from a large amount of different modules. - [#​17795](withastro/astro#17795) [`15e2deb`](withastro/astro@15e2deb) Thanks [@​matthewp](https://github.com/matthewp)! - Adds concurrent rendering support for `experimental.incrementalBuild`, including when using `@astrojs/cloudflare` Incremental builds no longer disable caching when `build.concurrency` is greater than `1`. Projects that set `build.concurrency: 1` to keep the cache enabled can remove that workaround. Cloudflare builds also reduce serialization overhead for large prerendered pages. - [#​17879](withastro/astro#17879) [`21c34a6`](withastro/astro@21c34a6) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes missing styles, links, and scripts from content collection entries rendered inside server islands - [#​17861](withastro/astro#17861) [`3193988`](withastro/astro@3193988) Thanks [@​ethanstoner](https://github.com/ethanstoner)! - Fixes i18n fallback routes being generated with a corrupted path when the locale code also appears at the start of a later path segment. A page such as `src/pages/en/enterprise.astro` with `fallback: { es: 'en' }` produced the route `/es/esterprise` instead of `/es/enterprise`, so the fallback never matched the intended URL. Only the leading locale segment is rewritten now. </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC42NS41IiwidXBkYXRlZEluVmVyIjoiNDQuNjUuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
consolecalls with the logger insteadTesting
Added
Docs