Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastify logger serializers not beign preserved on production build #13

Open
luiz opened this issue Dec 8, 2022 · 4 comments
Open

Fastify logger serializers not beign preserved on production build #13

luiz opened this issue Dec 8, 2022 · 4 comments

Comments

@luiz
Copy link

luiz commented Dec 8, 2022

I'm trying to register logger serializers for Fastify inside astro.config.mjs and they work in dev mode, but when I run astro build, the resulting dist/server/entry.mjs does not have the serializers configured inside it.

I tried to create a minimal example here: https://github.com/luiz/astro-fastify-logger-serializer

@matthewp
Copy link
Owner

Hey, sorry, I intended to reply but forgot too.

The problem is that we build your app for production but astro.config.mjs does not get built. That means only options that can be JSON.stringifyed work. There's a note on this in the readme:

Note that these options are built into the production bundle, so options such as logger.stream do not work.

A possible solution for this is to provide a hook, possible a special export in your entry where you can configure all of the fastify options. That would give you complete control but happen when we create the fastify instance.

Let me know what you think about that idea. If we wind up going that way it might make sense to deprecate the logger option as it can be confusing.

@luiz
Copy link
Author

luiz commented Dec 19, 2022

Hi, thanks for the reply!

I saw that note in the readme but wasn't sure it was related to this issue. The way you explained made a lot of sense to me! Maybe the readme note could explicitly mention "options that can be JSON.stringifyed work".

The idea of having a hook for configuring the Fastify options sounds really nice! In that case, deprecating the logger option sounds very reasonable.

@smnbbrv
Copy link
Contributor

smnbbrv commented Mar 22, 2023

hi @matthewp are there news regarding this? Could we elaborate?

@matthewp
Copy link
Owner

Not from me. If someone else wants to propose a hook and take on the work I'd happily accept though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants