From 0fd30f25e1e8eac87df11bf78a0e45b75655d55f Mon Sep 17 00:00:00 2001 From: ematipico Date: Wed, 22 Apr 2026 12:25:16 +0100 Subject: [PATCH 1/6] feat: astro logger --- astro.sidebar.ts | 1 + .../reference/experimental-flags/logger.mdx | 218 ++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 src/content/docs/en/reference/experimental-flags/logger.mdx diff --git a/astro.sidebar.ts b/astro.sidebar.ts index f2bcf97c84029..9cc4c15349db2 100644 --- a/astro.sidebar.ts +++ b/astro.sidebar.ts @@ -158,6 +158,7 @@ export const sidebar = [ 'reference/experimental-flags/svg-optimization', 'reference/experimental-flags/queued-rendering', 'reference/experimental-flags/rust-compiler', + 'reference/experimental-flags/logger', ], }), 'reference/legacy-flags', diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx new file mode 100644 index 0000000000000..247ce27bead4c --- /dev/null +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -0,0 +1,218 @@ +--- +title: Configuring logger +sidebar: + label: Logger +i18nReady: true +--- + +import Since from '~/components/Since.astro'; + +

+ +**Type:** `object`
+**Default:** `undefined`
+ +

+ +Enables an experimental, custom logger that can be controlled by the user. + +When provided, the user has total control over the logs emitted by Astro. Additionally, the feature comes with some built-in loggers that can be used via the new `logHandlers`. + +In the following example, we enable the built-in JSON logger, with a pretty output. + +```js title="astro.config.mjs" {5} ins="logHandlers" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.json({ pretty: true }) + } +}); +``` + +Alternatively, you can enable JSON logging the `dev`, `build` and `sync` commands using the `--experimentalJson` flag: + +```shell +astro dev --experimentalJson +astro sync --experimentalJson +astro build --experimentalJson +``` + + +## Built-in loggers + +The feature comes with three built-in loggers. + +### `logHandlers.json` + +A logger that outputs messages in a JSON format. A log would look like this: +```json +{ "message": "", "label": "router", "level": "info", "time": "" } +``` + +The `json` function accepts the following options: + +

+**Type:** `{ pretty: bool, level: AstroLoggerLevel }`
+**Default:** `{ pretty: false, level: 'info' }` + +

+ +- `pretty`: when `true`, the JSON log in printed on multiple lines. Defaults to `false` +- `level`: the [level](#log-level) of logs that should be printed. + +```js title="astro.config.mjs" {5} ins="json" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.json({ pretty: true }) + } +}); +``` + +### `logHandlers.console` + +A logger that print messages using `console` as its destination. Based on the level of the message, it uses different channels: +- `error` messages are printed using `console.error` +- `warn` messages are printed using `console.warn` +- `info` messages are printed using `console.info` + +The function accepts the following options: + +

+**Type:** `{ level: AstroLoggerLevel }`
+**Default:** `{ level: 'info' }` + +

+ +- `level`: the [level](#log-level) of logs that should be printed. + +```js title="astro.config.mjs" {5} ins="console" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.console({ level: 'warn' }) + } +}); +``` + +### `logHandlers.node` + +A logger that print messages to [`process.stdout`](https://nodejs.org/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/api/process.html#processstderr). Level `error` messages are printed to `stderr`, while the others are printed to `stdout`. + +This is Astro's default logger. + +The function accepts the following options: + +

+**Type:** `{ level: AstroLoggerLevel }`
+**Default:** `{ level: 'info' }` + +

+ +- `level`: the [level](#log-level) of logs that should be printed. + +```js title="astro.config.mjs" {5} ins="node" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.node({ level: 'warn' }) + } +}); +``` + +## Custom loggers + +You can create a custom logger by providing the correct configuration to the `logger` setting. It accepts an object with a mandatory `entrypoint`, the module where the logger is exported, and an optional configuration to pass to the logger. The configuration must be serializable. + +The logger function must be exported as `default`. + +When you define a custom logger, you are in charge of all logs, even the ones emitted by Astro. + +The following example, a custom logger is defined and exported by the package `@org/custom-logger`, and it accepts an object with only `level` defined. + +```js title="astro.config.mjs" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: { + entrypoint: "@org/custom-logger", + config: { + level: "warn" + } + } + } +}); +``` + +```ts title="@org/custom-logger/index.ts" +import type { + AstroLoggerLevel, + AstroLoggerDestination, + AstroLoggerMessage +} from "astro"; +import { matchesLevel } from "astro/logger"; + +type LoggerOptions = { + level: AstroLoggerLevel +} + +function orgLogger(options: LoggerOptions = {}): AstroLoggerDestination { + const { level = 'info' } = options; + return { + write(message: AstroLoggerMessage) { + // Use utility to understand if the message should be printed + if (matchesLevel(message.level, level)) { + // log message somewhere and take level into consideration + } + } + } +} + +export default orgLogger; +``` + +Custom loggers must comply with the `AstroLoggerDestination` interface, and the function `write` is mandatory. + +## Runtime + +The types [context object](/en/reference/api-reference/#the-context-object) now expose `logger` object that exposes the following functions: + +- `error()`, which emits an message with `error` level. +- `warn()`, which emits an message with `warn` level. +- `info()`, which emits an message with `info` level. + +```astro +--- +Astro.logger.error("This is an error"); +Astro.logger.warn("This is a warning"); +Astro.logger.info("This is an info"); +--- +``` + +## Log level + +A level is an internal, arbitrary score, assigned to each message. When a logger is configured with a certain level, only the messages with equals level is equal or higher are printed.Custom + +There are three levels, from the highest to the lowest score: +1. `error` +1. `warn` +1. `info` + +In the following example, we configure the JSON logger to print only messages that have the `warn` level or higher: + +```js title="astro.config.mjs" {5} ins='level: "warn"' +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.json({ level: "warn" }) + } +}); +``` + + From 8f2f10c63e99532dea3867046d6e4eb9580d28ef Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 24 Apr 2026 13:43:45 +0100 Subject: [PATCH 2/6] Apply suggestions from code review Co-authored-by: Armand Philippot --- .../reference/experimental-flags/logger.mdx | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx index 247ce27bead4c..5b7558463a6c1 100644 --- a/src/content/docs/en/reference/experimental-flags/logger.mdx +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -1,5 +1,5 @@ --- -title: Configuring logger +title: Experimental logger sidebar: label: Logger i18nReady: true @@ -18,7 +18,7 @@ Enables an experimental, custom logger that can be controlled by the user. When provided, the user has total control over the logs emitted by Astro. Additionally, the feature comes with some built-in loggers that can be used via the new `logHandlers`. -In the following example, we enable the built-in JSON logger, with a pretty output. +The following example enables the built-in JSON logger, with a pretty output: ```js title="astro.config.mjs" {5} ins="logHandlers" import { defineConfig, logHandlers } from 'astro/config'; @@ -50,15 +50,17 @@ A logger that outputs messages in a JSON format. A log would look like this: { "message": "", "label": "router", "level": "info", "time": "" } ``` -The `json` function accepts the following options: +#### JSON logger options

-**Type:** `{ pretty: bool, level: AstroLoggerLevel }`
+**Type:** `{ pretty: boolean; level: AstroLoggerLevel; }`
**Default:** `{ pretty: false, level: 'info' }`

-- `pretty`: when `true`, the JSON log in printed on multiple lines. Defaults to `false` +The `json` logger accepts the following options: + +- `pretty`: when `true`, the JSON log is printed on multiple lines. Defaults to `false` - `level`: the [level](#log-level) of logs that should be printed. ```js title="astro.config.mjs" {5} ins="json" @@ -73,12 +75,12 @@ export default defineConfig({ ### `logHandlers.console` -A logger that print messages using `console` as its destination. Based on the level of the message, it uses different channels: +A logger that prints messages using the `console` as its destination. Based on the level of the message, it uses different channels: - `error` messages are printed using `console.error` - `warn` messages are printed using `console.warn` - `info` messages are printed using `console.info` -The function accepts the following options: +#### Console logger options

**Type:** `{ level: AstroLoggerLevel }`
@@ -86,6 +88,8 @@ The function accepts the following options:

+The `console` logger accepts the following options: + - `level`: the [level](#log-level) of logs that should be printed. ```js title="astro.config.mjs" {5} ins="console" @@ -100,11 +104,11 @@ export default defineConfig({ ### `logHandlers.node` -A logger that print messages to [`process.stdout`](https://nodejs.org/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/api/process.html#processstderr). Level `error` messages are printed to `stderr`, while the others are printed to `stdout`. +A logger that prints messages to [`process.stdout`](https://nodejs.org/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/api/process.html#processstderr). Level `error` messages are printed to `stderr`, while the others are printed to `stdout`. This is Astro's default logger. -The function accepts the following options: +#### Node logger options

**Type:** `{ level: AstroLoggerLevel }`
@@ -112,6 +116,8 @@ The function accepts the following options:

+The `node` logger accepts the following options: + - `level`: the [level](#log-level) of logs that should be printed. ```js title="astro.config.mjs" {5} ins="node" @@ -132,7 +138,7 @@ The logger function must be exported as `default`. When you define a custom logger, you are in charge of all logs, even the ones emitted by Astro. -The following example, a custom logger is defined and exported by the package `@org/custom-logger`, and it accepts an object with only `level` defined. +The following example defines a custom logger exported by the `@org/custom-logger` package and accepting only one parameter to configure the logging `level`: ```js title="astro.config.mjs" import { defineConfig, logHandlers } from 'astro/config'; @@ -149,6 +155,8 @@ export default defineConfig({ }); ``` +The following example implements a minimal logger returning an `AstroLoggerDestination` object with the required `write()` function: + ```ts title="@org/custom-logger/index.ts" import type { AstroLoggerLevel, @@ -176,11 +184,9 @@ function orgLogger(options: LoggerOptions = {}): AstroLoggerDestination { export default orgLogger; ``` -Custom loggers must comply with the `AstroLoggerDestination` interface, and the function `write` is mandatory. - ## Runtime -The types [context object](/en/reference/api-reference/#the-context-object) now expose `logger` object that exposes the following functions: +The [context object](/en/reference/api-reference/#the-context-object) now exposes a `logger` object containing the following functions: - `error()`, which emits an message with `error` level. - `warn()`, which emits an message with `warn` level. @@ -196,14 +202,14 @@ Astro.logger.info("This is an info"); ## Log level -A level is an internal, arbitrary score, assigned to each message. When a logger is configured with a certain level, only the messages with equals level is equal or higher are printed.Custom +A level is an internal, arbitrary score, assigned to each message. When a logger is configured with a certain level, only the messages with equals level is equal or higher are printed. There are three levels, from the highest to the lowest score: 1. `error` -1. `warn` -1. `info` +2. `warn` +3. `info` -In the following example, we configure the JSON logger to print only messages that have the `warn` level or higher: +The following example configures the JSON logger to print only messages that have the `warn` level or higher: ```js title="astro.config.mjs" {5} ins='level: "warn"' import { defineConfig, logHandlers } from 'astro/config'; From 41999b4d2089af84dd9cc5843a78184003ac484b Mon Sep 17 00:00:00 2001 From: ematipico Date: Fri, 24 Apr 2026 15:05:18 +0100 Subject: [PATCH 3/6] feedback --- .../reference/experimental-flags/logger.mdx | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx index 5b7558463a6c1..e63796361c1ba 100644 --- a/src/content/docs/en/reference/experimental-flags/logger.mdx +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -130,6 +130,25 @@ export default defineConfig({ }); ``` +### `logHandlers.compose` + +A particular function that allows using multiple loggers. The same message is broadcasted to all loggers. The function accepts an arbitrary number of logger configurations.logHandlers + +The following example composes the console logger and JSON logger using the default log level: + +```js title="astro.config.mjs" +import { defineConfig, logHandlers } from 'astro/config'; + +export default defineConfig({ + experimental: { + logger: logHandlers.compose( + logHandlers.console(), + logHandlers.json() + ) + } +}); +``` + ## Custom loggers You can create a custom logger by providing the correct configuration to the `logger` setting. It accepts an object with a mandatory `entrypoint`, the module where the logger is exported, and an optional configuration to pass to the logger. The configuration must be serializable. @@ -141,7 +160,7 @@ When you define a custom logger, you are in charge of all logs, even the ones em The following example defines a custom logger exported by the `@org/custom-logger` package and accepting only one parameter to configure the logging `level`: ```js title="astro.config.mjs" -import { defineConfig, logHandlers } from 'astro/config'; +import { defineConfig } from 'astro/config'; export default defineConfig({ experimental: { @@ -219,6 +238,54 @@ export default defineConfig({ logger: logHandlers.json({ level: "warn" }) } }); -``` +``` + +We will expose an utility form the `astro/logger` package to check the log level. + +```js +import { matchesLevel } from "astro/logger" + +matchesLevel("error", "info"); +``` + + +## Types reference + +The following types can be imported from the `astro` specifier. + +### `AstroLoggerDestination` + +This is the interface that custom loggers must implement. The following can be implemented: +- `write(message: AstroLoggerMessage) => void`: a mandatory method that accepts a `AstroLoggerMessage`. It's called for every log. +- `flush() => Promise | void`: an optional function that is called at end of each request. Useful for advanced loggers for flushing logger messages while keeping the connection to the destination alive. +- `close() => Promise | void`: an optional function that is called before a server is shut down. This is a function usually called by adapters such as `@astrojs/node`. + +### `AstroLoggerLevel` + +The level of the message. + +### `AstroLoggerMessage` +The incoming object from the `AstroLoggerDestination.write` function: +- `message: string`: the message being logged. +- `level`: the level of the message. +- `label`: an arbitrary label assigned to the log message. +- `newLine`: whether this message should add a trailing newline. +## APIs reference + +The following APIs can me imported from the `astro/logger` specifier. + +### `matchesLevel` + +`matchesLevel(messageLevel: AstroLoggerLevel, configuredLevel: AstroLoggerLevel): boolean` + +Given two [logger level](#log-level), it returns whether the first level matches the second level. + +```js +import { matchesLevel } from "astro/logger" + +matchesLevel("error", "info"); // true +matchesLevel("info", "error"); // false + +``` From 4a21df6ed3ff33dc6f588836c5093313c8dab59e Mon Sep 17 00:00:00 2001 From: ematipico Date: Fri, 24 Apr 2026 15:06:42 +0100 Subject: [PATCH 4/6] feedback --- .../docs/en/reference/experimental-flags/logger.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx index e63796361c1ba..527f0703fc107 100644 --- a/src/content/docs/en/reference/experimental-flags/logger.mdx +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -262,7 +262,12 @@ This is the interface that custom loggers must implement. The following can be i ### `AstroLoggerLevel` -The level of the message. +The level of the message. Available variants: +- `'debug'` +- `'info'` +- `'warn'` +- `'error'` +- `'silent'` ### `AstroLoggerMessage` From 4bd118fbd2e1a794f0e797bf0485b843f89081ea Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 27 Apr 2026 09:34:02 +0100 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Armand Philippot --- .../reference/experimental-flags/logger.mdx | 53 +++++++++++++++---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx index 527f0703fc107..4ff316e51652f 100644 --- a/src/content/docs/en/reference/experimental-flags/logger.mdx +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -132,7 +132,7 @@ export default defineConfig({ ### `logHandlers.compose` -A particular function that allows using multiple loggers. The same message is broadcasted to all loggers. The function accepts an arbitrary number of logger configurations.logHandlers +A particular function that allows configuring multiple loggers in an arbitrary order. The same message is broadcasted to all loggers. The following example composes the console logger and JSON logger using the default log level: @@ -174,7 +174,7 @@ export default defineConfig({ }); ``` -The following example implements a minimal logger returning an `AstroLoggerDestination` object with the required `write()` function: +The following example implements a minimal logger returning an [`AstroLoggerDestination` object](#astrologgerdestination) with the required `write()` function: ```ts title="@org/custom-logger/index.ts" import type { @@ -240,7 +240,7 @@ export default defineConfig({ }); ``` -We will expose an utility form the `astro/logger` package to check the log level. +The `astro/logger` package exposes a [`matchesLevel()`](#matcheslevel) helper to check the log level. This can be useful when [building a custom logger](#custom-loggers). ```js import { matchesLevel } from "astro/logger" @@ -255,10 +255,34 @@ The following types can be imported from the `astro` specifier. ### `AstroLoggerDestination` -This is the interface that custom loggers must implement. The following can be implemented: -- `write(message: AstroLoggerMessage) => void`: a mandatory method that accepts a `AstroLoggerMessage`. It's called for every log. -- `flush() => Promise | void`: an optional function that is called at end of each request. Useful for advanced loggers for flushing logger messages while keeping the connection to the destination alive. -- `close() => Promise | void`: an optional function that is called before a server is shut down. This is a function usually called by adapters such as `@astrojs/node`. +This is the interface that custom loggers must implement. + +#### `AstroLoggerDestination.write()` + +

+ +**Type:** `(message: AstroLoggerMessage) => void` +

+ +A mandatory method called for each log and accepting an [`AstroLoggerMessage`](#astrologgermessage). + +#### `AstroLoggerDestination.flush()` + +

+ +**Type:** `() => Promise | void` +

+ +An optional function called at the end of each request. This is useful for advanced loggers that need to flush log messages while keeping the connection to the destination alive. + +#### `AstroLoggerDestination.close()` + +

+ +**Type:** `() => Promise | void` +

+ +An optional function called before a server is shut down. This function is usually called by adapters such as `@astrojs/node`. ### `AstroLoggerLevel` @@ -271,8 +295,12 @@ The level of the message. Available variants: ### `AstroLoggerMessage` -The incoming object from the `AstroLoggerDestination.write` function: -- `message: string`: the message being logged. +

+ +**Type:** `{ label: string | null; level: AstroLoggerLevel; message: string; newLine: boolean; }` +

+The incoming object from the [`AstroLoggerDestination.write()`](#astrologgerdestinationwrite) function: +- `message`: the message being logged. - `level`: the level of the message. - `label`: an arbitrary label assigned to the log message. - `newLine`: whether this message should add a trailing newline. @@ -283,9 +311,12 @@ The following APIs can me imported from the `astro/logger` specifier. ### `matchesLevel` -`matchesLevel(messageLevel: AstroLoggerLevel, configuredLevel: AstroLoggerLevel): boolean` +

+ +**Type:** `matchesLevel(messageLevel: AstroLoggerLevel, configuredLevel: AstroLoggerLevel) => boolean` +

-Given two [logger level](#log-level), it returns whether the first level matches the second level. +Given two [log levels](#log-level), it returns whether the first level matches the second level. ```js import { matchesLevel } from "astro/logger" From c7c6e53a59af3866cb655d9bae27e944095ccfb3 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 28 Apr 2026 14:50:30 +0100 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com> --- .../reference/experimental-flags/logger.mdx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/content/docs/en/reference/experimental-flags/logger.mdx b/src/content/docs/en/reference/experimental-flags/logger.mdx index 4ff316e51652f..8f1be3cba772c 100644 --- a/src/content/docs/en/reference/experimental-flags/logger.mdx +++ b/src/content/docs/en/reference/experimental-flags/logger.mdx @@ -30,7 +30,7 @@ export default defineConfig({ }); ``` -Alternatively, you can enable JSON logging the `dev`, `build` and `sync` commands using the `--experimentalJson` flag: +Alternatively, you can enable JSON logging for the `dev`, `build`, and `sync` commands using the `--experimentalJson` flag: ```shell astro dev --experimentalJson @@ -60,7 +60,7 @@ A logger that outputs messages in a JSON format. A log would look like this: The `json` logger accepts the following options: -- `pretty`: when `true`, the JSON log is printed on multiple lines. Defaults to `false` +- `pretty`: when `true`, the JSON log is printed on multiple lines. Defaults to `false`. - `level`: the [level](#log-level) of logs that should be printed. ```js title="astro.config.mjs" {5} ins="json" @@ -76,9 +76,10 @@ export default defineConfig({ ### `logHandlers.console` A logger that prints messages using the `console` as its destination. Based on the level of the message, it uses different channels: -- `error` messages are printed using `console.error` -- `warn` messages are printed using `console.warn` -- `info` messages are printed using `console.info` + +- `error` messages are printed using `console.error()`. +- `warn` messages are printed using `console.warn()`. +- `info` messages are printed using `console.info()`. #### Console logger options @@ -132,7 +133,7 @@ export default defineConfig({ ### `logHandlers.compose` -A particular function that allows configuring multiple loggers in an arbitrary order. The same message is broadcasted to all loggers. +A particular function that allows configuring multiple loggers in an arbitrary order. The same message is broadcast to all loggers. The following example composes the console logger and JSON logger using the default log level: @@ -192,9 +193,9 @@ function orgLogger(options: LoggerOptions = {}): AstroLoggerDestination { const { level = 'info' } = options; return { write(message: AstroLoggerMessage) { - // Use utility to understand if the message should be printed + // Use this utility to understand if the message should be printed if (matchesLevel(message.level, level)) { - // log message somewhere and take level into consideration + // log message somewhere and take the level into consideration } } } @@ -207,9 +208,9 @@ export default orgLogger; The [context object](/en/reference/api-reference/#the-context-object) now exposes a `logger` object containing the following functions: -- `error()`, which emits an message with `error` level. -- `warn()`, which emits an message with `warn` level. -- `info()`, which emits an message with `info` level. +- `error()`, which emits a message with `error` level. +- `warn()`, which emits a message with `warn` level. +- `info()`, which emits a message with `info` level. ```astro --- @@ -221,7 +222,7 @@ Astro.logger.info("This is an info"); ## Log level -A level is an internal, arbitrary score, assigned to each message. When a logger is configured with a certain level, only the messages with equals level is equal or higher are printed. +A level is an internal, arbitrary score assigned to each message. When a logger is configured with a certain level, only the messages with a level equal to or higher are printed. There are three levels, from the highest to the lowest score: 1. `error` @@ -243,7 +244,7 @@ export default defineConfig({ The `astro/logger` package exposes a [`matchesLevel()`](#matcheslevel) helper to check the log level. This can be useful when [building a custom logger](#custom-loggers). ```js -import { matchesLevel } from "astro/logger" +import { matchesLevel } from "astro/logger"; matchesLevel("error", "info"); ``` @@ -307,7 +308,7 @@ The incoming object from the [`AstroLoggerDestination.write()`](#astrologgerdest ## APIs reference -The following APIs can me imported from the `astro/logger` specifier. +The following APIs can be imported from the `astro/logger` specifier. ### `matchesLevel` @@ -319,7 +320,7 @@ The following APIs can me imported from the `astro/logger` specifier. Given two [log levels](#log-level), it returns whether the first level matches the second level. ```js -import { matchesLevel } from "astro/logger" +import { matchesLevel } from "astro/logger"; matchesLevel("error", "info"); // true matchesLevel("info", "error"); // false