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

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

Open
andredias opened this issue Sep 23, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@andredias
Copy link
Owner

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 andredias self-assigned this Sep 23, 2023
@andredias andredias added the enhancement New feature or request label Sep 23, 2023
@andredias
Copy link
Owner Author

Better logging will help to:

  • Have a sense of the response time of your API so you can improve slow-responding endpoints.
  • Be able to debug a specific request and reproduce them to test a fix.

@daylightZhang
Copy link

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
Copy link
Owner Author

Thanks!

@jcity
Copy link

jcity commented Jan 11, 2024

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 😂)

@andredias
Copy link
Owner Author

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

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

No branches or pull requests

3 participants