Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
ArmandPhilippot
left a comment
There was a problem hiding this comment.
Thanks Ema! I left a few suggestions mostly around:
- docs style, consistency with other experimental pages
- and some reorganization to make it easier to scan. For example I find the API block placement a bit annoying currently:
Also, I noticed you mentioned the AstroLoggerDestination but I don't think we document its exact shape at the moment. It would be helpful to have a "Types reference" section with the public types/types required to build a custom logger.
Then, when the feature becomes stable we only need to reorganize the contents, everything would already be here.
For example, the experimental Route caching has an API reference but we could also use the same format used in the other references (e.g. Renderer types).
| @@ -0,0 +1,218 @@ | |||
| --- | |||
| title: Configuring logger | |||
There was a problem hiding this comment.
We usually put "Experimental" in the title:
| title: Configuring logger | |
| title: Experimental logger |
Or if you think this is important to keep "configuring" here:
| title: Configuring logger | |
| title: Experimental logger configuration |
|
|
||
| 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. |
There was a problem hiding this comment.
We avoid "we" in docs:
| 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: |
| <Since v="6.2.0" /> | ||
| </p> | ||
|
|
||
| - `pretty`: when `true`, the JSON log in printed on multiple lines. Defaults to `false` |
There was a problem hiding this comment.
typo?
| - `pretty`: when `true`, the JSON log in printed on multiple lines. Defaults to `false` | |
| - `pretty`: when `true`, the JSON log is printed on multiple lines. Defaults to `false` |
| The `json` function accepts the following options: | ||
|
|
||
| <p> | ||
| **Type:** `{ pretty: bool, level: AstroLoggerLevel }`<br /> | ||
| **Default:** `{ pretty: false, level: 'info' }` | ||
| <Since v="6.2.0" /> | ||
| </p> |
There was a problem hiding this comment.
The API block before the list looks a bit weird in the preview. But I get the intent: this is the type for the configuration object not for logHandlers.json().
I wonder if a heading for the options could help here:
| The `json` function accepts the following options: | |
| <p> | |
| **Type:** `{ pretty: bool, level: AstroLoggerLevel }`<br /> | |
| **Default:** `{ pretty: false, level: 'info' }` | |
| <Since v="6.2.0" /> | |
| </p> | |
| #### JSON logger options | |
| <p> | |
| **Type:** `{ pretty: boolean; level: AstroLoggerLevel; }`<br /> | |
| **Default:** `{ pretty: false, level: 'info' }` | |
| <Since v="6.2.0" /> | |
| </p> | |
| The `json` logger accepts the following options: |
What do you think?
| The function accepts the following options: | ||
|
|
||
| <p> | ||
| **Type:** `{ level: AstroLoggerLevel }`<br /> | ||
| **Default:** `{ level: 'info' }` | ||
| <Since v="6.2.0" /> | ||
| </p> |
There was a problem hiding this comment.
Same as before, this currently looks a bit weird in the preview and I wonder if a heading for the options could help here:
| The function accepts the following options: | |
| <p> | |
| **Type:** `{ level: AstroLoggerLevel }`<br /> | |
| **Default:** `{ level: 'info' }` | |
| <Since v="6.2.0" /> | |
| </p> | |
| #### Console logger options | |
| <p> | |
| **Type:** `{ level: AstroLoggerLevel }`<br /> | |
| **Default:** `{ level: 'info' }` | |
| <Since v="6.2.0" /> | |
| </p> | |
| The `console` logger accepts the following options: |
|
|
||
| Custom loggers must comply with the `AstroLoggerDestination` interface, and the function `write` is mandatory. |
There was a problem hiding this comment.
Then, this is no longer necessary:
| 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: |
There was a problem hiding this comment.
Maybe this is the barrier language but "types" sounds odd to me here. Could we use this instead:
| 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: |
|
|
||
| ## 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 was a problem hiding this comment.
I guess this was the auto completion trying to add something after the dot?
| 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. |
| 1. `error` | ||
| 1. `warn` | ||
| 1. `info` |
There was a problem hiding this comment.
Well, this is correctly rendered but they all have the same score currently 😅
| 1. `error` | |
| 1. `warn` | |
| 1. `info` | |
| 1. `error` | |
| 2. `warn` | |
| 3. `info` |
| 1. `warn` | ||
| 1. `info` | ||
|
|
||
| In the following example, we configure the JSON logger to print only messages that have the `warn` level or higher: |
There was a problem hiding this comment.
Same as earlier, we avoid "we" in docs:
| 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: |
I was hoping to get some suggestions on where to have it, and if it needs an header |
|
If there is only one useful type, a reference section might not be the best approach and we could reshape
(we don't necessarily need to show Otherwise, a new section at the end might be easier to organize the content. Each section only describe what is available and we add links to the relevant types for advanced users. This remains easy to scan without having to scroll too much for those not interested in building their own logger. Something like:
And we have precedents for both approaches, so the structure remains familiar to users. |


Description (required)
This PR adds documentation for the upcoming experimental logger. The RFC is here: withastro/roadmap#1339
Linear: AST-84
For Astro version:
6.2.0. See astro PR #16437.The attached PR is the one that mostly documents the new APIs