andredias / perfect_python_project

42 stars 12 forks source link

Create a default handler to log uncaught exceptions in FastAPI projects #5

Open andredias opened 11 months ago

andredias commented 11 months ago

Improve FastAPI (minimum and complete) projects to log uncaught errors.

Other ideas that can be used are well presented at FastAPI Server Errors And Logs — Take Back Control

andredias commented 11 months ago

Better logging will help to:

daylightZhang commented 8 months ago

Your template is exactly what I've always wanted to create; it's even more perfect than I had imagined. 😍 Thanks for your work and hopefully i could contribute my work on it in the future.

andredias commented 8 months ago

Thanks!

jcity commented 8 months ago

This is a fantastic template! I discovered it from your blog post

It looks like you already added this feature. One enhancement I think that could be made is to print the exception stack traces nicely. This could be configured by environment so that if you're running locally, it prints like a normal stack trace but in production (where presumable you can format during your log pipeline) it prints compactly.

I'll give this a shot - if you're up for it, I'll submit a PR (if I can get it working :joy:)

andredias commented 8 months ago

Hey, Justin! I appreciate any contribution you can provide. Thanks!