blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js
https://Blitzjs.com
MIT License
13.68k stars 798 forks source link

Blitz logging #3808

Closed stychu closed 1 year ago

stychu commented 2 years ago

What do you want and why?

It seems that currently there is no way to connect to the current logger of the blitz app either to modify nor to extract the logs. I would expect to be able to use current logging solution to log relevant things as I want and whenever I want for debugging purposes especially in production env. On top of that I should be able to get the logs in a file so I could process them however I want. This is especially necessary for self hosted blitz apps using docker etc. This should be prioritised before stable release of 2.0

Possible implementation(s)

Ideally logging should be generic so people could use either blitz logging approach or incorporate their own solutions. Mostly being able to connect with the most popular logging libraries like winston pino bunyan would be desirable option

dillondotzip commented 2 years ago

setupBlitzServer inside app/blitz-server.ts has an onError(e) property.

There's a PR opened for this in the docs but hasn't been merged yet https://github.com/blitz-js/blitzjs.com/pull/750

stychu commented 2 years ago

onError(e) property. is not sufficient. Sophisticated logging over application in places where developer want is what we need. Attaching only to error logs from blitz is not enough. Logging any extra meta information from within custom files/queries/mutations is needed.

stychu commented 2 years ago

I guess creating a custom server would make this work so then you can use custom logger as described here https://blitzjs.com/docs/custom-server

But what do I loose making a custom server is the question. Ideally I would like to just use blitz server as it is and just attach to it's logger 🐻