dart_frog
dart_frog copied to clipboard
feat: logger support
Description
As a developer, I want to be able to have either integrated 1st party support or a recommended 3rd party logger which seamlessly integrates with dart_frog and provides the functionality described in the requirements section.
Requirements
- [ ] Standard Logging Levels
- [ ] Flexible API which can support logging-specific requirements for various cloud platforms
- [ ] API which can support configuring log-levels based on the environment (e.g. debug in development and notice in production)
Hi there 👋 I agree this is a very important thing to add!
Personally, I would add a few more requirements that would be super nice to have:
- [ ] Automatically logging uncaught errors in handlers in the correct format
- [ ] Included middleware so it works "out of the box"
Because of these, I propose we use something like this repository that I set up to demonstrate how I think a dart_frog logger should work. You can check it out now - instructions are in the README (although I haven't published it to pub.dev yet so you'll have to add it as a git dependency for now).
A few reasons I think this is a great solution:
- It covers all the requirements laid out in the issue and my comment
- It exposes a simple
typedef
LogFormatter
so that it's super easy to define your own log style if you'd like - In a separate library, it includes a built-in support for Google Cloud Logging and a simple log format for local development
- It includes information like source location and stacktraces in the logs
- It uses
very_good_analysis
and has 100% coverage - It only depends on
shelf
and notdart_frog
so it works just as well with a raw shelf API
Lastly, I really think it's good to have the logger not built into the framework but instead as a separate package that can be added in through middleware.
The bold part of me proposes we migrate the existing repository to the /packages
directory and rename it dart_frog_logger
. I could also write a page on the docs site showing how to use it.
Let me know what you think 💙 I'm sure my package isn't perfect, but hopefully can at least share ideas and at most make this a super easy ticket to close 😎