From 46c5584a44c510a86740ff215ec5dfc3814f12cb Mon Sep 17 00:00:00 2001 From: Ronit Date: Tue, 7 Jul 2026 02:48:06 +0530 Subject: [PATCH 1/5] feat: export AstroComponentLogger type --- packages/astro/src/types/public/context.ts | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/astro/src/types/public/context.ts b/packages/astro/src/types/public/context.ts index 8172a31e66cd..ef992dd591fa 100644 --- a/packages/astro/src/types/public/context.ts +++ b/packages/astro/src/types/public/context.ts @@ -129,6 +129,26 @@ export interface AstroGlobal< }; } +/** + * The `AstroComponentLogger` exposes the logging functions available to Astro components, endpoints, and middleware. + * + * [Astro reference](https://docs.astro.build/en/reference/api-reference/#logger) + */ +export interface AstroComponentLogger { + /** + * Logs a message with `info` level. + */ + info: (msg: string) => void; + /** + * Logs a message with `warn` level. + */ + warn: (msg: string) => void; + /** + * Logs a message with `error` level. + */ + error: (msg: string) => void; +} + /** * The `APIContext` is the object made available to endpoints and middleware. * It is a subset of the `Astro` global object available in pages. @@ -579,20 +599,7 @@ export interface APIContext< /** * It exposes utilities for logging messages. */ - logger: { - /** - * Logs a message with `info` level. - */ - info: (msg: string) => void; - /** - * Logs a message with `warn` level. - */ - warn: (msg: string) => void; - /** - * Logs a message with `error` level. - */ - error: (msg: string) => void; - }; + logger: AstroComponentLogger; /** * The route currently rendered. It's stripped of the `srcDir` and the `pages` folder, and it doesn't contain the extension. From feeeceaa67d117932c6ba8ca95fef7856c18049d Mon Sep 17 00:00:00 2001 From: Ronit Date: Tue, 7 Jul 2026 02:49:29 +0530 Subject: [PATCH 2/5] chore: add changeset for AstroComponentLogger --- .changeset/export-logger.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/export-logger.md diff --git a/.changeset/export-logger.md b/.changeset/export-logger.md new file mode 100644 index 000000000000..50f6ceac9f7e --- /dev/null +++ b/.changeset/export-logger.md @@ -0,0 +1,5 @@ +--- +"astro": minor +--- + +Export `AstroComponentLogger` public type for the runtime logger From c11e50062f9863e1ecdd2a10a24f8480b4cec1d7 Mon Sep 17 00:00:00 2001 From: Ronit Sonawane Date: Tue, 7 Jul 2026 13:43:46 +0530 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Emanuele Stoppa --- .changeset/export-logger.md | 5 +++-- packages/astro/src/types/public/context.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.changeset/export-logger.md b/.changeset/export-logger.md index 50f6ceac9f7e..52db06af1020 100644 --- a/.changeset/export-logger.md +++ b/.changeset/export-logger.md @@ -1,5 +1,6 @@ --- -"astro": minor +"astro": patch --- -Export `AstroComponentLogger` public type for the runtime logger +Fixes a bug where users couldn't properly type the logger functions at runtime. Now users can import `AstroRuntimeLogger`. + diff --git a/packages/astro/src/types/public/context.ts b/packages/astro/src/types/public/context.ts index ef992dd591fa..fd089229917b 100644 --- a/packages/astro/src/types/public/context.ts +++ b/packages/astro/src/types/public/context.ts @@ -130,11 +130,11 @@ export interface AstroGlobal< } /** - * The `AstroComponentLogger` exposes the logging functions available to Astro components, endpoints, and middleware. + * A type containing functions for logging messages. * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#logger) */ -export interface AstroComponentLogger { +export interface AstroRuntimeLogger { /** * Logs a message with `info` level. */ From 4bc6c559ae3ba369a5ab2b92e11d7856f6fc6c5d Mon Sep 17 00:00:00 2001 From: Ronit Date: Tue, 7 Jul 2026 14:03:13 +0530 Subject: [PATCH 4/5] fix: update APIContext logger to AstroRuntimeLogger --- packages/astro/src/types/public/context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/types/public/context.ts b/packages/astro/src/types/public/context.ts index fd089229917b..5d77e4133b0f 100644 --- a/packages/astro/src/types/public/context.ts +++ b/packages/astro/src/types/public/context.ts @@ -599,7 +599,7 @@ export interface APIContext< /** * It exposes utilities for logging messages. */ - logger: AstroComponentLogger; + logger: AstroRuntimeLogger; /** * The route currently rendered. It's stripped of the `srcDir` and the `pages` folder, and it doesn't contain the extension. From fdf226024da6bc78270c67d4edb89b6814099779 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 7 Jul 2026 10:40:37 +0100 Subject: [PATCH 5/5] Update .changeset/export-logger.md Co-authored-by: Armand Philippot --- .changeset/export-logger.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/export-logger.md b/.changeset/export-logger.md index 52db06af1020..c472c0c0b770 100644 --- a/.changeset/export-logger.md +++ b/.changeset/export-logger.md @@ -2,5 +2,5 @@ "astro": patch --- -Fixes a bug where users couldn't properly type the logger functions at runtime. Now users can import `AstroRuntimeLogger`. +Exposes the `AstroRuntimeLogger` interface to allow users to properly type the logger functions at runtime.