Skip to content

feat: stable logger#13907

Open
ematipico wants to merge 6 commits into
mainfrom
feat/custom-logger
Open

feat: stable logger#13907
ematipico wants to merge 6 commits into
mainfrom
feat/custom-logger

Conversation

@ematipico
Copy link
Copy Markdown
Member

@ematipico ematipico commented May 18, 2026

Description (required)

This PR adds documentation for the logger APIs, which will be stable soon

For Astro version: 6.4.0. See astro PR #16745.

@ematipico ematipico added merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day. labels May 18, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 90dde15
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/6a0c83735624ca0008037e0a
😎 Deploy Preview https://deploy-preview-13907--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Copy Markdown
Contributor

astrobot-houston commented May 18, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/reference/api-reference.mdx Source changed, localizations will be marked as outdated.
en/reference/logger-reference.mdx Localization added, will be marked as complete.
ko/reference/experimental-flags/logger.mdx Localization removed, will be marked as missing.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
Copy Markdown
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

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

Already! Ahah, you move too fast for the French reviewers... I guess I can close #13830 😅

Speaking of that, the link error is because of the Korean translation. We usually delete the translations as well when we stabilize an experimental feature.

I know the content hasn't changed much... maybe we should consider renaming the translation and using a Lunaria directive in a case like this. But, I believe Junseong is able to easily browse the Git history to recover its translation so we can remove it for now.

I left a few suggestions to be consistent with our other references (a bit more verbose in some places, functions notation).

Is Astro.logger particularly useful with custom loggers? If so, maybe we should add a link to /en/reference/api-reference/#logger to improve its discoverability. If not, no change needed!

Also, I noticed we now have loggerConfig in SSRManifest. We'll need a new section in https://docs.astro.build/en/reference/integrations-reference/#ssrmanifest

Comment thread src/content/docs/en/reference/api-reference.mdx
Comment thread src/content/docs/en/reference/api-reference.mdx Outdated
Comment thread src/content/docs/en/reference/api-reference.mdx Outdated
Comment thread src/content/docs/en/reference/api-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
@ArmandPhilippot ArmandPhilippot added this to the 6.4 milestone May 18, 2026
ematipico and others added 2 commits May 19, 2026 15:21
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
@github-actions github-actions Bot added the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label May 19, 2026
@ematipico
Copy link
Copy Markdown
Member Author

ematipico commented May 19, 2026

Is Astro.logger particularly useful with custom loggers? If so, maybe we should add a link to /en/reference/api-reference/#logger to improve its discoverability. If not, no change needed!

It's the whole point! Ahahaha. Dufus me that I completely overlooked this important connection. The important thing is that the runtime APIs are always at user's disposal regardless of a custom logger, but with a custom logger users have more control.

My last commit added a small paragraph with the link

Comment thread src/content/docs/en/reference/logger-reference.mdx Outdated
ematipico and others added 2 commits May 19, 2026 16:35
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Copy link
Copy Markdown
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

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

I was double checking, and I think this is almost ready.

  • In the SSRManifest reference, we need a section for loggerConfig. And, now we have a section for log levels, we should update the SSRManifest.logLevel description with a link to that section.
  • I left a question about log levels because debug and silent are also available but we do not explain how they differ.

Edit: I found another place https://docs.astro.build/en/reference/modules/astro-config/#imports-from-astroconfig we'll need to add logHandlers there. A good occasion to create a link to the Logger API there!

});
```

### `logHandlers.compose`
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.

I missed this one, parentheses for consistency:

Suggested change
### `logHandlers.compose()`

Comment on lines +78 to +81
There are three levels, from the highest to the lowest score:
1. `error`
2. `warn`
3. `info`
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.

I was going to say I'm a bit confused by this because in AstroLoggerLevel we also have debug and silent. So, 5 and not 3 levels. But, I just saw the unresolved question in the RFC:

debug info level has been kept out of the picture because we use obug for it, which is noisy and completely different from the rest of the logs. Should we keep it out? Docs should address the differences from normal logging.

It seems in the end we'll keep it? I guess this does not contribute to the score and this is a special case like silent, as this is not available in the runtime API. And, these two levels match the verbose and silent flags. Am I right?

In any case, we should probably have something explaining they are also available and how they differ.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

They were kept out on purpose because:

  • debug logging isn't astro logging. It involves obug, which also enables vite logging. It's a mess. I wanted to keep users out of it. Perhaps we could mention how our/users logging interact with debug logging
  • silent logging isn't really a level that you want to configure and/or use, right? Specifically Astro.logger.silent. Perhaps we could expand the docs of --silent to explain that users logs are hidden too

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.

Well, I was referring to levels because this is a value allowed by AstroLoggerLevel. Naming... 😄 But, yeah, I agree those are not levels. I just feel there is something missing and that could be confusing for the users too.

Maybe this section is fine as it is because this is about the real levels. And, maybe, the AstroLoggerLevel description should be reworked a little instead? I mean to link the possible values ​​and what they refer to. This way we can link back to the Log Level section for info, warn, and error, and to the CLI flags for silent and debug.

I'm not yet sure about the wording to make a suggestion (too late to have a clear head 😴 ) but it might make more sense than updating the Log level section...

But, yes, updating --silent sounds like a good idea!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll look into it, we shouldn't provide silent and debug levels to the user

Comment on lines 252 to 259
### `AstroLoggerLevel`

The level of the message. Available variants:
- `'debug'`
- `'info'`
- `'warn'`
- `'error'`
- `'silent'`
Copy link
Copy Markdown
Member

@ArmandPhilippot ArmandPhilippot May 20, 2026

Choose a reason for hiding this comment

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

So, what I meant last night in #13907 (comment) was that the AstroLoggerLevel section could look something like this:

Suggested change
### `AstroLoggerLevel`
<p>
**Type:** `'debug' |'info' |'warn' | 'error' | 'silent'`
</p>
Specifies the verbosity level of logs:
- `info`, `warn`, and `error`: defines the minimal [log level](#log-level) to print.
- `silent`: this is equivalent to the [`--silent` CLI flag](/en/reference/cli-reference/#--silent) and enables silent logging.
- `debug`: this is equivalent to the [`--debug` CLI flag](/en/reference/cli-reference/#--verbose) and enables verbose logging, including Vite logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) minor-release For the next minor release; in the milestone, "merge queue" = approved for merging on release day.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants