RFC: Custom logger on the start server #3286
zrosenbauer
started this conversation in
RFCs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
Currently all of the server-side logging is done via good ole'
console
but I'd like to be able to use a dedicated logger across the board. This would allow developers to hook into logging tools because the logs need to follow a certain format. If we are unable to do this I would be unable to create metrics etc.Solution
Provide a way for developers to inject a logger of their choice, such as
pino
orbunyan
.Note
There is already some-level of support via the middleware https://tanstack.com/start/latest/docs/framework/react/middleware
API
I'm proposing to mirror the API from Fastify (https://fastify.dev/docs/latest/Reference/Server/#loggerinstance) as it's well defined.
Polyfill / Example
I created a quick polyfill to test it out.
Output:
![Screenshot 2025-01-30 at 17 19 59](https://private-user-images.githubusercontent.com/3486461/408323063-9c44df52-f904-481e-a6bd-39fcc6a88303.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4NTQzNzgsIm5iZiI6MTczODg1NDA3OCwicGF0aCI6Ii8zNDg2NDYxLzQwODMyMzA2My05YzQ0ZGY1Mi1mOTA0LTQ4MWUtYTZiZC0zOWZjYzZhODgzMDMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDZUMTUwMTE4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzVmYTljMDU2NmMzYzQ5MzcyNDZhMjFhNDcwMDQyOTA2YTRkNWI0NWY4MzllZGMzZWNjZjVhNzVlMTBkZjAwMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.fzVn4YtXNKAdr4ivuhf9sqVTP7oGcQ4lsSj2B0EKsHg)
LOE
I'm not a 100% sure on the level of effort, but a quick search in VS Code under the
packages/start-*
dirs, I found 78 results across 29 files that include the textconsole.
.I don't believe ALL of these would need or should be migrated as some could be client-side, others could be migrated later just probably need to include the primary paths.
Questions
console.log
Beta Was this translation helpful? Give feedback.
All reactions