astro-fastify
astro-fastify copied to clipboard
Fastify logger serializers not beign preserved on production build
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
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.
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.
hi @matthewp are there news regarding this? Could we elaborate?
Not from me. If someone else wants to propose a hook and take on the work I'd happily accept though.