litestar
                                
                                
                                
                                    litestar copied to clipboard
                            
                            
                            
                        Add log_config and rich_logging attribs to app
Adds two new instance attributes to starlite.app.Starlite class.
- log_config - Takes in a dict of config options to pass to logging.dictConfig. Allows custom log configuration by the user.
 - rich_logging - Default False. If True, swaps out the default console log handler with a RichHandler. If rich isn't present when rich_logging = True, raises an ImproperlyConfiguredException
 
PR Checklist
- [ ] Have you followed the guidelines in 
CONTRIBUTING.md? - [ ] Have you got 100% test coverage on new code?
 - [ ] Have you updated the prose documentation?
 - [ ] Have you updated the reference documentation?
 
I'll probably need some help writing tests and docs for this assuming there are no changes needed.
@Goldziher Thanks for the feedback. I'll work on those. In the mean time, any advice on getting through the pre-commit checks? Looks like we might need to increase the number of allowed parameters to a function as well tell it not to worry about rich not being resolvable. Is there a better way of checking to see if rich is installed than importing it? Importlib?
@Goldziher Thanks for the feedback. I'll work on those. In the mean time, any advice on getting through the pre-commit checks? Looks like we might need to increase the number of allowed parameters to a function as well tell it not to worry about rich not being resolvable. Is there a better way of checking to see if rich is installed than importing it? Importlib?
For pylint - you can add too-many-statements to the disabled rules section for pylint in pyproject.toml:
[tool.pylint.MESSAGE_CONTROL]
disable = [
...
]
As for checking if something is installed - its standard practice to try to import something and catch ImportError. E.g.:
try:
   from rich import x
except ImportError:
   x = None
You can then test if x: etc.
whats the status of this?
whats the status of this?
I've been waiting to see what will happen with the logging middleware #411 . It looked like it was going to be merged soon and might have implications for this that might require big changes. In the mean time, do you have any advice for the failing tests?
Let's proceed with this one. Regardless of the other PR.
I'll look at the tests.
@john-ingles - you can rebase on main. It should fix the issue in CI
I think I'll close this draft because of #511's submission.
As you wish. I think you can add a simple PR for rich logging based on it. I am about to update it shortly.