-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Logging config #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the idea of emphasizing logging, and especially for something like a project-creation CLI. I think that's missing from a lot of microframeworks.
In terms of the implementation, I'm not 100% sure about whether:
-
Coupling the logging setup to the app is necessary. Django does do this sort of the same way - they call
dictConfig
behind the scenes for you, but it would also be possible to leave it out of the app and just provide asetup_logging
on_startup
callable when creating a project. That wouldn't hide away the one line of code that gets users to understand how the setup works. -
If creating a model for the dict config is necessary. I get that there's an upside in terms of validating input (and protecting users from themselves), but in some ways it feels like we'd just be obscuring the already well-known python API.
I'll think about it some more. Do you have any thoughts re ^ @Goldziher?
Well, as to the points:
|
cec327c
to
f686874
Compare
Maybe consider shipping with |
I think one thing this project should strive for, is not deviating too far from Starlette or other starlette-derivatives. Being able to drop-in replace your project app and have things work with your existing configuration is a big plus. Shipping with loguru would break my projects, and it's just one of several similar libraries (e.g., structlog) that do fancy logging. I think shipping with it would be locking us in with a third party lib without a great reason 🙂 |
Loguru is created to solve this problem, and nothing else. I personally don't use it in my projects, but in my opinion it does a great job of simplifying setup.
Not sure if being able to drop-in replace should be something to strive for, it seems very limiting for an opinionated framework.
While I suggest adding They can also live side by side, if desired:
|
Updated my previous comment. |
What's the upside of using loguru vs structlog or vanilla logging with something like the rich logging handler? |
That it is user friendly. You literally say As with this library, it is opinionated. It has defaults, handlers for file rotation etc. These defaults could be changed to include correlation-ids, API paths etc. That way it requires zero setup from the end user. If they want to configure any logs, they can either use the built in Implementation on starlite logs could maybe even be something like this: try:
from loguru import logger
except:
import logging
logger = logging.getLogger(__name__) I'm not saying it's the way to go, but I think it could be interesting to see its upsides and downsides. |
Interesting. For me the main point of logging is to output useful, machine processable, information that can be searched. E.g. elastic search, data dig etc. Colorized output really doesn't matter, although it might be cool. The point really is simplicity. I wait the user to have working logging from the getgo, and still retain control of configuration. Thoughts? I am not against Amy solution suggested by you guys so far. |
It might make sense to build something like this into a starter-project template, but I think the framework should be very careful about constraining the user in any way - because you cannot predict user requirements. Maybe not the best example, but as an illustration: let's say a user needs a dependency |
Yeah, this might be true for all logging and a bunch of extra features honestly. Logging can be hard, but a CLI would probably be sufficient.
While (I managed to delete the branch when trying to click |
� This is the 1st commit message: integrate msgspec into signature modelling � The commit message #2 will be skipped: � Add dependency injection of classes (#1143) � � * add support for classes in dependency injection � � * Apply suggestions from code review � � Co-authored-by: Janek Nouvertné <25355197+provinzkraut@users.noreply.github.com> � � * address review comments � � --------- � � Co-authored-by: Janek Nouvertné <25355197+provinzkraut@users.noreply.github.com>
This PR adds a default logging config and a way of setting logging easily: